Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 25th, 2012  |  syntax: None  |  size: 3.53 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to combine Tim Heuer navigation framework template with MVVM Light
  2. <UserControl x:Class="Valachy.Administration.Views.MainPage"
  3.          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4.          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5.          xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6.          xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"            
  7.          xmlns:Helpers="clr-namespace:Valachy.Administration.Helpers"
  8.          xmlns:res="clr-namespace:Valachy.Administration.Resources"
  9.          xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
  10.          xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
  11.          d:DesignWidth="640" d:DesignHeight="480"
  12.          mc:Ignorable="d"            
  13.          DataContext="{Binding Main, Source={StaticResource Locator}}">
  14.  
  15. <UserControl.Resources>
  16.     <ResourceDictionary>
  17.         <ResourceDictionary.MergedDictionaries>
  18.             <ResourceDictionary Source="../Skins/MainSkin.xaml" />
  19.             <ResourceDictionary>
  20.                 <Helpers:ResourceWrapper x:Key="ResourceWrapper" />
  21.                 <Helpers:NotOperatorValueConverter x:Key="NotOperatorValueConverter" />
  22.             </ResourceDictionary>
  23.         </ResourceDictionary.MergedDictionaries>
  24.     </ResourceDictionary>
  25. </UserControl.Resources>
  26.  
  27. <Grid x:Name="LayoutRoot">
  28.     <StackPanel Orientation="Horizontal" VerticalAlignment="Top">
  29.         <StackPanel Orientation="Horizontal" Width="250">
  30.             <HyperlinkButton Click="NavigateButtonClick" Tag="Home" Content="Home" FontFamily="24"></HyperlinkButton>
  31.             <HyperlinkButton Click="NavigateButtonClick" Tag="/Views/Tasks.xaml" Content="Tasks" FontFamily="24"></HyperlinkButton>
  32.             <HyperlinkButton Click="NavigateButtonClick" Tag="/Views/TaskPlans.xaml" Content="Plans" FontFamily="24"></HyperlinkButton>
  33.         </StackPanel>
  34.     </StackPanel>
  35.     <navigation:Frame x:Name="MainFrame" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Margin="20" Source="/Views/Home.xaml"  />
  36. </Grid>
  37. </UserControl>
  38.        
  39. private void NavigateButtonClick(object sender, System.Windows.RoutedEventArgs e)
  40.     {
  41.         HyperlinkButton hyperlinkButton = sender as HyperlinkButton;
  42.         if (hyperlinkButton != null)
  43.         {
  44.             string urlString = hyperlinkButton.Tag.ToString();                
  45.             Uri url = new Uri(urlString,UriKind.Relative);
  46.             MainFrame.Navigate(url);
  47.         }
  48.     }
  49.        
  50. <Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  51.          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  52.          x:Class="Valachy.Administration.App"
  53.          xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  54.          xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  55.          xmlns:vm="clr-namespace:Valachy.Administration.ViewModel"
  56.          xmlns:navcore="clr-namespace:System.Windows.Navigation;assembly=System.Windows.Controls.Navigation"
  57.          mc:Ignorable="d">
  58. <Application.Resources>
  59.  
  60.     <!--Global View Model Locator-->
  61.     <vm:ViewModelLocator x:Key="Locator"
  62.                          d:IsDataSource="True" />
  63.     <navcore:UriMapper x:Key="uriMapper">            
  64.         <navcore:UriMapping Uri="Home" MappedUri="/Views/Home.xaml" />
  65.         <navcore:UriMapping Uri="Tasks" MappedUri="/Views/Tasks.xaml" />
  66.         <navcore:UriMapping Uri="TaskPlans" MappedUri="/Views/TaskPlans.xaml" />
  67.     </navcore:UriMapper>
  68. </Application.Resources>
  69. </Application>