Skip to content

Instantly share code, notes, and snippets.

@BrianJVarley
Last active August 29, 2015 14:21
Show Gist options
  • Save BrianJVarley/842e56610473c9217acc to your computer and use it in GitHub Desktop.
Save BrianJVarley/842e56610473c9217acc to your computer and use it in GitHub Desktop.
<Page x:Class="LC_Points.View.ViewSubjectGradePage"
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:LC_Points.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
mc:Ignorable="d">
<Grid x:Name="LayoutRoot">
<Grid.ChildrenTransitions>
<TransitionCollection>
<EntranceThemeTransition />
</TransitionCollection>
</Grid.ChildrenTransitions>
<Grid.RowDefinitions>
<RowDefinition Height="40*" />
<RowDefinition Height="20*" />
<RowDefinition Height="30*" />
<RowDefinition Height="30*" />
<RowDefinition Height="20*" />
<RowDefinition Height="20*" />
</Grid.RowDefinitions>
<!-- Title Panel -->
<StackPanel Grid.Row="0" Margin="19,0,0,0">
<TextBlock Margin="0,12,0,0"
Style="{ThemeResource TitleTextBlockStyle}"
Text="LC POINTS" />
<TextBlock Margin="0,-6.5,0,26.5"
CharacterSpacing="{ThemeResource PivotHeaderItemCharacterSpacing}"
Foreground="DarkGreen"
Style="{ThemeResource HeaderTextBlockStyle}"
Text="View Grades" />
</StackPanel>
<!-- TODO: Content should be placed within the following grid -->
<Grid x:Name="ContentRoot"
Grid.Row="1"
Margin="19,9.5,19,0">
<ListBox Height="400"
Margin="0,0,0,-329"
VerticalAlignment="Top"
ItemsSource="{Binding AddedSubjectGradePairsCopy}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock>
<Run Text="{Binding Subject}" /><Run Text=" - " /><Run Text="{Binding Points}" />
</TextBlock>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Grid>
</Page>
using LC_Points.Common;
using LC_Points.Model;
using LC_Points.ViewModel;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Graphics.Display;
using Windows.UI.Popups;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Basic Page item template is documented at http://go.microsoft.com/fwlink/?LinkID=390556
namespace LC_Points.View
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class ViewSubjectGradePage : Page
{
private NavigationHelper navigationHelper;
public ViewSubjectGradePage()
{
this.InitializeComponent();
this.navigationHelper = new NavigationHelper(this);
this.navigationHelper.LoadState += this.NavigationHelper_LoadState;
this.navigationHelper.SaveState += this.NavigationHelper_SaveState;
this.DataContext = new ViewSubjectGradeViewModel();
}
/// <summary>
/// Gets the <see cref="NavigationHelper"/> associated with this <see cref="Page"/>.
/// </summary>
public NavigationHelper NavigationHelper
{
get { return this.navigationHelper; }
}
/// <summary>
/// Populates the page with content passed during navigation. Any saved state is also
/// provided when recreating a page from a prior session.
/// </summary>
/// <param name="sender">
/// The source of the event; typically <see cref="NavigationHelper"/>
/// </param>
/// <param name="e">Event data that provides both the navigation parameter passed to
/// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
/// a dictionary of state preserved by this page during an earlier
/// session. The state will be null the first time a page is visited.</param>
private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
{
}
/// <summary>
/// Preserves state associated with this page in case the application is suspended or the
/// page is discarded from the navigation cache. Values must conform to the serialization
/// requirements of <see cref="SuspensionManager.SessionState"/>.
/// </summary>
/// <param name="sender">The source of the event; typically <see cref="NavigationHelper"/></param>
/// <param name="e">Event data that provides an empty dictionary to be populated with
/// serializable state.</param>
private void NavigationHelper_SaveState(object sender, SaveStateEventArgs e)
{
}
#region NavigationHelper registration
/// <summary>
/// The methods provided in this section are simply used to allow
/// NavigationHelper to respond to the page's navigation methods.
/// <para>
/// Page specific logic should be placed in event handlers for the
/// <see cref="NavigationHelper.LoadState"/>
/// and <see cref="NavigationHelper.SaveState"/>.
/// The navigation parameter is available in the LoadState method
/// in addition to page state preserved during an earlier session.
/// </para>
/// </summary>
/// <param name="e">Provides data for navigation methods and event
/// handlers that cannot cancel the navigation request.</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
this.navigationHelper.OnNavigatedTo(e);
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
this.navigationHelper.OnNavigatedFrom(e);
}
#endregion
}
}
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Ioc;
using LC_Points.Model;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Text;
namespace LC_Points.ViewModel
{
public class ViewSubjectGradeViewModel : ViewModelBase
{
/// <summary>
/// Initializes a new instance of the ViewSubjectGradeViewModel class.
/// </summary>
public ViewSubjectGradeViewModel()
{
AddedSubjectGradePairs = new ObservableCollection<ScoreModel>();
}
private ObservableCollection<ScoreModel> _addedSubjectGradePairs;
public ObservableCollection<ScoreModel> AddedSubjectGradePairs
{
get { return _addedSubjectGradePairs; }
set
{
if (value != _addedSubjectGradePairs)
{
_addedSubjectGradePairs = value;
RaisePropertyChanged("AddedSubjectGradePairs");
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment