Skip to content

Instantly share code, notes, and snippets.

@BrianJVarley
Created January 30, 2016 22:14
Show Gist options
  • Save BrianJVarley/99e7786046c38a2d3763 to your computer and use it in GitHub Desktop.
Save BrianJVarley/99e7786046c38a2d3763 to your computer and use it in GitHub Desktop.
<Page x:Class="Parking_Tag_Picker_WRT.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Parking_Tag_Picker_WRT"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
mc:Ignorable="d">
<Grid x:Name="LayoutRoot" Background="#FF236A93">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel x:Name="TitlePanel"
Grid.Row="0"
Margin="12,17,0,28">
<TextBlock Style="{StaticResource SubheaderTextBlockStyle}" Text="Parking Tag Picker" />
<TextBlock Margin="9,-7,0,0"
Style="{StaticResource HeaderTextBlockStyle}"
Text="Council Zones" />
</StackPanel>
<Grid x:Name="ContentPanel"
Grid.Row="1"
Margin="12,0,12,0">
<ListView x:Name="ZonesListView"
Margin="0,0,-12,0"
ItemsSource="{Binding CouncilNameItems}"
SelectedItem="{Binding SelectedCouncilName}">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,17">
<TextBlock Style="{ThemeResource ListViewItemTextBlockStyle}"
Text="{Binding CouncilAcronym}"
TextWrapping="Wrap" />
<TextBlock Margin="12,-6,12,0"
Style="{ThemeResource ListViewItemSubheaderTextBlockStyle}"
Text="{Binding CouncilFullName}"
TextWrapping="Wrap" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
<!--
Uncomment to see an alignment grid to help ensure your controls are
aligned on common boundaries. The image has a top margin of -32px to
account for the System Tray. Set this to 0 (or remove the margin altogether)
if the System Tray is hidden.
Before shipping remove this XAML and the image itself.
-->
<!--<Image Source="/Assets/AlignmentGrid.png" VerticalAlignment="Top" Height="800" Width="480" Margin="0,-32,0,0" Grid.Row="0" Grid.RowSpan="2" IsHitTestVisible="False" />-->
</Grid>
</Page>
using GalaSoft.MvvmLight;
using Parking_Tag_Picker_WRT.Interfaces;
using Parking_Tag_Picker_WRT.Models;
using System.Collections.ObjectModel;
namespace Parking_Tag_Picker_WRT.ViewModel
{
/// <summary>
/// This class contains properties that the main View can data bind to.
/// <para>
/// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel.
/// </para>
/// <para>
/// You can also use Blend to data bind with the tool's support.
/// </para>
/// <para>
/// See http://www.galasoft.ch/mvvm
/// </para>
/// </summary>
public class MainViewModel : ViewModelBase
{
private INavigationCallback _navCallBack = null;
/// <summary>
/// Initializes a new instance of the MainViewModel class.
/// </summary>
public MainViewModel()
{
this.CouncilNameItems = new ObservableCollection<CouncilNameModel>();
}
/// <summary>
/// Creates and adds council name data.
/// </summary>
public void LoadCouncilNamesData()
{
//Load Council Names
this.CouncilNameItems.Add(new CouncilNameModel() { ID = "0", CouncilAcronym = "DCC", CouncilFullName = "Dublin City Council" });
this.CouncilNameItems.Add(new CouncilNameModel() { ID = "1", CouncilAcronym = "DLR", CouncilFullName = "Dún Laoghaire-Rathdown County Council" });
this.CouncilNameItems.Add(new CouncilNameModel() { ID = "2", CouncilAcronym = "FCC", CouncilFullName = "Fingal County Council" });
this.CouncilNameItems.Add(new CouncilNameModel() { ID = "3", CouncilAcronym = "SDC", CouncilFullName = "South Dublin County Council" });
this.CouncilNameItems.Add(new CouncilNameModel() { ID = "4", CouncilAcronym = "ATC", CouncilFullName = "Arklow Town Council" });
this.CouncilNameItems.Add(new CouncilNameModel() { ID = "5", CouncilAcronym = "DLH", CouncilFullName = "Dún Laoghaire Harbour Company" });
this.CouncilNameItems.Add(new CouncilNameModel() { ID = "6", CouncilAcronym = "WTC", CouncilFullName = "Wicklow Town Council" });
this.CouncilNameItems.Add(new CouncilNameModel() { ID = "7", CouncilAcronym = "TS", CouncilFullName = "Tallaght Stadium" });
this.CouncilNameItems.Add(new CouncilNameModel() { ID = "8", CouncilAcronym = "GS", CouncilFullName = "Greystones" });
this.IsDataLoaded = true;
}
public ObservableCollection<CouncilNameModel> CouncilNameItems { get; private set; }
public bool IsDataLoaded { get; private set; }
private CouncilNameModel _selectedCouncilName;
public CouncilNameModel SelectedCouncilName
{
get
{
return this._selectedCouncilName;
}
set
{
_navCallBack.NavigateTo(_selectedCouncilName.ID);
if (value != _selectedCouncilName)
{
_selectedCouncilName = value;
RaisePropertyChanged("SelectedCouncilName");
}
}
}
public INavigationCallback NavigationCallback
{
get { return _navCallBack; }
set { _navCallBack = value; }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment