Skip to content

Instantly share code, notes, and snippets.

@andy51002000
andy51002000 / MovieDetailView.xaml.cs
Created October 22, 2017 10:08
MovieDetailView Code behind that handle navigation between each views
using Common;
using SimpleMVVM.Models;
using SimpleMVVM.ViewModels;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
namespace SimpleMVVM
{
@andy51002000
andy51002000 / MovieDetailView.xaml
Created October 22, 2017 10:10
A View that present Movie detail
<Page
x:Class="SimpleMVVM.MovieDetailView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SimpleMVVM"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
HorizontalAlignment="Left"
DataContext="{Binding Source={StaticResource ViewModelLocator}, Path=MovieDetailViewModel}"
@andy51002000
andy51002000 / partial App.cs
Created October 22, 2017 10:26
partial code of App.cs
public static NavigationService NavigationService;
/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
Frame rootFrame = Window.Current.Content as Frame;
@andy51002000
andy51002000 / MovieDetailViewModel.cs
Created October 22, 2017 12:54
A ViewModel of MovieDetailView
using SimpleMVVM.Data;
using SimpleMVVM.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace SimpleMVVM.ViewModels
@andy51002000
andy51002000 / Updated ViewModelLocator.cs
Created October 22, 2017 12:55
Update for MovieDetailViewModel
using SimpleMVVM.Data;
using System.Collections.Generic;
namespace SimpleMVVM.ViewModels
{
public class ViewModelLocator
{
private Dictionary<string, ViewModelBase> modSet;
private FakeDatabase dbContext;
@andy51002000
andy51002000 / MovieDetailView.xaml
Created October 22, 2017 12:57
A View that present Movie detail
<Page
x:Class="SimpleMVVM.MovieDetailView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SimpleMVVM"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
HorizontalAlignment="Left"
DataContext="{Binding Source={StaticResource ViewModelLocator}, Path=MovieDetailViewModel}"
@andy51002000
andy51002000 / MovieDetailView.xaml.cs
Created October 22, 2017 13:00
MovieDetailView Code Behind that uses NavigationHelper to handler navigation state
using Common;
using SimpleMVVM.Models;
using SimpleMVVM.ViewModels;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
namespace SimpleMVVM
{
@andy51002000
andy51002000 / partial of MovieListviewModel.cs
Created October 22, 2017 13:06
Partial code of MovieListviewModel that handle SelectedChanged for ListBox of view
public void selectedMovieChanged()
{
if(SelectedMovie !=null)
App.NavigationService.Navigate<MovieDetailView>(SelectedMovie);
}
@andy51002000
andy51002000 / Updated MovieListView.xaml.cs
Last active October 22, 2017 13:08
Updated MovieListView.xaml.cs for navigation
using Common;
using SimpleMVVM.ViewModels;
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.UI.Xaml;
@andy51002000
andy51002000 / Updated MovieListView.xaml
Created October 22, 2017 13:11
Updated for ListBox_SelectionChanged
<Page
x:Class="SimpleMVVM.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SimpleMVVM"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
DataContext="{Binding Source= {StaticResource ViewModelLocator}, Path=MovieListViewModel}"
>