Last active
August 29, 2015 14:25
-
-
Save BrianJVarley/a74eb399b3fb772db3bf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Page x:Class="LC_Points.MainPage" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:Core="using:Microsoft.Xaml.Interactions.Core" | |
xmlns:Interactivity="using:Microsoft.Xaml.Interactivity" | |
xmlns:Series="using:WinRTXamlToolkit.Controls.DataVisualization.Charting" | |
xmlns:charting="using:WinRTXamlToolkit.Controls.DataVisualization.Charting" | |
xmlns:controls="using:WinRTXamlToolkit.Controls" | |
xmlns:converter="using:LC_Points.Converter" | |
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |
xmlns:datavis="using:WinRTXamlToolkit.Controls.DataVisualization" | |
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" | |
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" | |
xmlns:local="using:LC_Points" | |
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" | |
mc:Ignorable="d"> | |
<Page.Resources> | |
<converter:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" /> | |
<converter:BoolToNonVisibilityConverter x:Key="BoolToNonVisibilityConverter" /> | |
</Page.Resources> | |
<Grid> | |
<Grid.RowDefinitions> | |
<RowDefinition Height="40*" /> | |
<RowDefinition Height="20*" /> | |
<RowDefinition Height="30*" /> | |
<RowDefinition Height="30*" /> | |
<RowDefinition Height="20*" /> | |
<RowDefinition Height="20*" /> | |
</Grid.RowDefinitions> | |
<Grid.ColumnDefinitions> | |
<ColumnDefinition Width="4*" /> | |
<ColumnDefinition Width="3*" /> | |
</Grid.ColumnDefinitions> | |
<StackPanel x:Name="TitlePanel" | |
Grid.Row="0" | |
Margin="12,17,0,28"> | |
<TextBlock Style="{StaticResource SubheaderTextBlockStyle}" Text="LC POINTS" /> | |
<TextBlock Margin="9,-7,0,0" | |
Foreground="DarkGreen" | |
Style="{StaticResource HeaderTextBlockStyle}" | |
Text="Home" /> | |
</StackPanel> | |
<!-- TitlePanel contains the name of the application and page title --> | |
<ComboBox x:Name="subjectCmbBx" | |
Grid.Row="1" | |
Grid.ColumnSpan="2" | |
Width="199" | |
HorizontalAlignment="Left" | |
VerticalAlignment="Top" | |
DisplayMemberPath="Subject" | |
Header="Subjects" | |
ItemsSource="{Binding Subjects}" | |
PlaceholderText="Pick a subject" | |
SelectedItem="{Binding SelectedSubject, | |
Mode=TwoWay}" /> | |
<ComboBox x:Name="ordinaryGradeCmbBx" | |
Grid.Row="1" | |
Grid.Column="0" | |
Grid.ColumnSpan="2" | |
Width="170" | |
HorizontalAlignment="Right" | |
DisplayMemberPath="Key" | |
Header="Grades" | |
ItemsSource="{Binding OrdinaryGradePointKV}" | |
PlaceholderText="Pick a grade" | |
SelectedValue="{Binding SelectedOrdinaryGrade, | |
Mode=TwoWay}" | |
Visibility="{Binding IsHigher, | |
Mode=TwoWay, | |
Converter={StaticResource BoolToNonVisibilityConverter}}" /> | |
<ComboBox x:Name="higherGradeCmbBx" | |
Grid.Row="1" | |
Grid.Column="0" | |
Grid.ColumnSpan="2" | |
Width="170" | |
HorizontalAlignment="Right" | |
DisplayMemberPath="Key" | |
Header="Grades" | |
ItemsSource="{Binding HigherGradePointKV}" | |
PlaceholderText="Pick a grade" | |
SelectedValue="{Binding SelectedHigherGrade, | |
Mode=TwoWay}" | |
Visibility="{Binding IsHigher, | |
Mode=TwoWay, | |
Converter={StaticResource BoolToVisibilityConverter}}" /> | |
//This button enable property is bound to the combo boxes being selected -----> | |
<Button x:Name="addGradeBtn" | |
Grid.Row="2" | |
HorizontalAlignment="Left" | |
Command="{Binding Path=AddGradeCommand}" | |
Content="Add Grade" | |
IsEnabled="{Binding ButtonEnabled, | |
Mode=TwoWay}" /> | |
</Grid> | |
</Page> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace LC_Points.ViewModel | |
{ | |
public class MainViewModel : ViewModelBase | |
{ | |
private readonly IRepository<ScoreModel> _repository = App.ScoresRepository; | |
/// <summary> | |
/// Initializes a new instance of the MainViewModel class. | |
/// </summary> | |
public MainViewModel() | |
{ | |
//call methods to initilise list data | |
InitSubjectTypes(); | |
InitOrdinaryGradePairs(); | |
InitHigherGradePairs(); | |
} | |
public List<ScoreModel> Subjects { get; set; } | |
public List<StringKeyValue> HigherGradePointKV { get; set; } | |
public List<StringKeyValue> OrdinaryGradePointKV { get; set; } | |
//Button enabled binding set based on the combo boxes being selected --> | |
private ScoreModel _selectedSubject; | |
public ScoreModel SelectedSubject | |
{ | |
get { return _selectedSubject; } | |
set | |
{ | |
if (value != _selectedSubject) | |
{ | |
_selectedSubject = value; | |
RaisePropertyChanged("SelectedSubject"); | |
ButtonEnabled = true; | |
} | |
} | |
} | |
private StringKeyValue _selectedHigherGrade; | |
public StringKeyValue SelectedHigherGrade | |
{ | |
get { return _selectedHigherGrade; } | |
set | |
{ | |
if (value != _selectedHigherGrade) | |
{ | |
_selectedHigherGrade = value; | |
RaisePropertyChanged("SelectedHigherGrade"); | |
ButtonEnabled = true; | |
} | |
else | |
{ | |
ButtonEnabled = false; | |
} | |
} | |
} | |
private StringKeyValue _selectedOrdinaryGrade; | |
public StringKeyValue SelectedOrdinaryGrade | |
{ | |
get { return _selectedOrdinaryGrade; } | |
set | |
{ | |
if (value != _selectedOrdinaryGrade) | |
{ | |
_selectedOrdinaryGrade = value; | |
RaisePropertyChanged("SelectedOrdinaryGrade"); | |
ButtonEnabled = true; | |
} | |
else | |
{ | |
ButtonEnabled = false; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment