Click here to Skip to main content
15,881,715 members
Articles / Programming Languages / C# 4.0

Silverlight DataTrigger is the Answer to View Model / MVVM Issues

Rate me:
Please Sign up or sign in to vote.
5.00/5 (32 votes)
6 Nov 2010Ms-PL4 min read 137.8K   1.4K   54  
How using the Silverlight DataTrigger allows you to run a process and then raise another when using View Model (MVVM)
  • viewmodeltreecontrol2.zip
    • ViewModelTreeControl.sln
    • ViewModelTreeControl.Web
    • ViewModelTreeControl
      • App.xaml
      • App.xaml.cs
      • Assets
      • Bin
        • Debug
          • AppManifest.xaml
          • ar
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • bg
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • ca
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • cs
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • da
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • de
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.Navigation.resources.dll
            • System.Windows.Controls.resources.dll
            • System.Windows.Data.resources.dll
          • el
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • es
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.Navigation.resources.dll
            • System.Windows.Controls.resources.dll
            • System.Windows.Data.resources.dll
          • et
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • eu
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • fi
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • fr
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.Navigation.resources.dll
            • System.Windows.Controls.resources.dll
            • System.Windows.Data.resources.dll
          • he
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • hr
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • hu
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • id
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • it
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.Navigation.resources.dll
            • System.Windows.Controls.resources.dll
            • System.Windows.Data.resources.dll
          • ja
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.Navigation.resources.dll
            • System.Windows.Controls.resources.dll
            • System.Windows.Data.resources.dll
          • ko
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.Navigation.resources.dll
            • System.Windows.Controls.resources.dll
            • System.Windows.Data.resources.dll
          • lt
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • lv
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • Microsoft.Expression.Interactions.dll
          • Microsoft.Expression.Interactions.xml
          • ms
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • nl
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • no
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • pl
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • pt
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • pt-BR
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • ro
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • ru
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.Navigation.resources.dll
            • System.Windows.Controls.resources.dll
            • System.Windows.Data.resources.dll
          • sk
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • sl
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • sr-Cyrl-CS
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • sr-Latn-CS
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • sv
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • System.ComponentModel.DataAnnotations.dll
          • System.ComponentModel.DataAnnotations.xml
          • System.Windows.Controls.Data.dll
          • System.Windows.Controls.Data.Input.dll
          • System.Windows.Controls.Data.Input.xml
          • System.Windows.Controls.Data.xml
          • System.Windows.Controls.dll
          • System.Windows.Controls.Input.dll
          • System.Windows.Controls.Input.xml
          • System.Windows.Controls.Navigation.dll
          • System.Windows.Controls.Navigation.xml
          • System.Windows.Controls.xml
          • System.Windows.Data.dll
          • System.Windows.Data.xml
          • System.Windows.Interactivity.dll
          • System.Windows.Interactivity.xml
          • TestPage.html
          • th
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • tr
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • uk
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • vi
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.resources.dll
          • ViewModelTreeControl.dll
          • ViewModelTreeControl.xap
          • zh-Hans
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.Navigation.resources.dll
            • System.Windows.Controls.resources.dll
            • System.Windows.Data.resources.dll
          • zh-Hant
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Controls.Input.resources.dll
            • System.Windows.Controls.Navigation.resources.dll
            • System.Windows.Controls.resources.dll
            • System.Windows.Data.resources.dll
        • Release
      • Classes
      • Controls
      • Images
        • backgroundshadow.png
        • backgroundtexture.png
      • MainPage.xaml
      • MainPage.xaml.cs
      • Properties
      • readme.txt
      • Unique Features of this Theme.txt
      • ViewModels
      • ViewModelTreeControl.csproj
      • ViewModelTreeControl.csproj.user
      • Views
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" xmlns:uriMapper="clr-namespace:System.Windows.Navigation;assembly=System.Windows.Controls.Navigation" xmlns:System="clr-namespace:System;assembly=mscorlib" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Brushes.xaml" />
        <ResourceDictionary Source="Fonts.xaml" />
        <ResourceDictionary Source="CoreStyles.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <!--
    ***************************************************************************
    A note about the width of the navigation app: this theme is designed to 
    max out at 960px. That keeps the content at a reasonable width on really
    big screens, but if you'd like to change it, it's easy to do! Just change
    the value of ContentMaxWidth (below). Or if you don't want a maxium width
    for the content, then just delete the lines where it shows up.
    ***************************************************************************
    -->

    <System:Double x:Key="ContentMaxWidth">960</System:Double>

    <!--
    ***************************************************************************
    Main Page Styles
    ***************************************************************************
    -->

    <!--LayoutRootGridStyle-->
    <Style x:Key="BackgroundBorderStyle" TargetType="Border">
        <Setter Property="Background">
            <Setter.Value>
                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                    <GradientStop Offset="0" Color="#30FFFFFF" />
                    <GradientStop Offset="0.5" Color="#00FFFFFF" />
                </LinearGradientBrush>        
            </Setter.Value>
        </Setter>
        <Setter Property="BorderBrush">
            <Setter.Value>
                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                    <GradientStop Offset="0" Color="#30000000" />
                    <GradientStop Offset="0.5" Color="#00000000" />
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="MaxWidth" Value="{StaticResource ContentMaxWidth}" />
        <Setter Property="BorderThickness" Value="1,0" />
    </Style>

    <!--LayoutRootGridStyle-->
    <Style x:Key="LayoutRootGridStyle" TargetType="Grid">
        <Setter Property="MaxWidth" Value="{StaticResource ContentMaxWidth}" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="Margin" Value="46,0" />
        <Setter Property="VerticalAlignment" Value="Top" />
    </Style>

    <!--ContentBorderStyle-->
    <Style x:Key="ContentBorderStyle" TargetType="Border">
        <Setter Property="Background" Value="{x:Null}" />
        <Setter Property="BorderBrush" Value="{x:Null}" />
        <Setter Property="BorderThickness" Value="0,0,0,0" />
        <Setter Property="Margin" Value="0,0,0,0" />
        <Setter Property="VerticalAlignment" Value="Stretch" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
    </Style>

    <!--ContentFrameStyle-->
    <Style x:Key="ContentFrameStyle" TargetType="navigation:Frame">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="Padding" Value="30,0" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    </Style>

    <!--NavigationGridStyle-->
    <Style x:Key="NavigationGridStyle" TargetType="Grid">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Height" Value="87" />
        <Setter Property="Margin" Value="30,0" />
        <Setter Property="VerticalAlignment" Value="Top" />
    </Style>

    <!--BrandingBorderStyle-->
    <Style x:Key="BrandingBorderStyle" TargetType="Border">
        <Setter Property="Height" Value="46" />
        <Setter Property="Margin" Value="30,0" />
        <Setter Property="VerticalAlignment" Value="Top" />
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="Padding" Value="0,5,0,0" />
    </Style>

    <!--BrandingStackPanelStyle-->
    <Style x:Key="BrandingStackPanelStyle" TargetType="StackPanel">
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="Orientation" Value="Vertical" />
    </Style>

    <!--LogoIcon-->
    <Style x:Key="LogoIcon" TargetType="ContentControl">
        <Setter Property="Content" Value="lorem ipsum dolor sit" />
        <Setter Property="Foreground" Value="{StaticResource NavigationForegroundColorBrush}" />
        <Setter Property="Height" Value="24" />
        <Setter Property="Margin" Value="0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ContentControl">
                    <Grid Margin="0,5,0,0">
                        <TextBlock Style="{StaticResource HeaderTextStyle}" Text="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" FontWeight="Normal" FontSize="{TemplateBinding FontSize}" Margin="10,4,0,0" VerticalAlignment="Center" Padding="0" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--ApplicationNameStyle-->
    <Style x:Key="ApplicationNameStyle" TargetType="TextBlock">
        <Setter Property="Foreground" Value="{StaticResource NavigationForegroundColorBrush}" />
        <Setter Property="FontFamily" Value="{StaticResource HeadingFontFamily}" />
        <Setter Property="FontSize" Value="{StaticResource Heading3FontSize}" />
        <Setter Property="FontWeight" Value="Bold" />
        <Setter Property="TextOptions.TextHintingMode" Value="Animated" />
        <Setter Property="Opacity" Value="0.5" />
        <Setter Property="Margin" Value="30,17,0,0" />
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="HorizontalAlignment" Value="Left" />
    </Style>

    <!--LinksBorderStyle-->
    <Style x:Key="LinksBorderStyle" TargetType="Border">
        <Setter Property="Background" Value="{StaticResource StaticControlBackground}" />
        <Setter Property="Effect" Value="{StaticResource ControlShadowEffect}" />
        <Setter Property="Height" Value="38" />
        <Setter Property="Margin" Value="0" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="VerticalAlignment" Value="Top" />
    </Style>

    <!--LinksStackPanelStyle-->
    <Style x:Key="LinksStackPanelStyle" TargetType="StackPanel">
        <Setter Property="VerticalAlignment" Value="Stretch" />
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="Orientation" Value="Horizontal" />
        <Setter Property="Height" Value="47" />
        <Setter Property="Margin" Value="0,0,0,0" />
    </Style>

    <!--LinkStyle-->
    <Style x:Key="LinkStyle" TargetType="HyperlinkButton">
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Background" Value="{StaticResource InputSelectionBrush}" />
        <Setter Property="BorderBrush" Value="{x:Null}" />
        <Setter Property="Foreground" Value="{StaticResource NavigationInactiveForegroundColorBrush}" />
        <Setter Property="FontFamily" Value="{StaticResource ContentFontFamily}" />
        <Setter Property="FontSize" Value="{StaticResource Heading5FontSize}" />
        <Setter Property="FontWeight" Value="Bold" />
        <Setter Property="TextOptions.TextHintingMode" Value="Animated" />
        <Setter Property="Cursor" Value="Hand" />
        <Setter Property="Height" Value="47" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="Padding" Value="24,4" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="HyperlinkButton">
                    <Grid x:Name="ButtonGrid" Cursor="{TemplateBinding Cursor}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="InteractiveElementBorder" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="InteractiveElementBorder" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.95" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="InteractiveBorder" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <EasingDoubleKeyFrame KeyTime="00:00:00" Value="1" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="InteractiveElementBorder" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="InteractiveElementBorder" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.8" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="InteractiveBorder" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <EasingDoubleKeyFrame KeyTime="00:00:00" Value="1" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="DisabledOverlay" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="(FrameworkElement.VerticalAlignment)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <VerticalAlignment>Center</VerticalAlignment>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="DisabledOverlay" Storyboard.TargetProperty="(FrameworkElement.HorizontalAlignment)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <HorizontalAlignment>Center</HorizontalAlignment>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="DisabledOverlay" Storyboard.TargetProperty="(FrameworkElement.VerticalAlignment)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <VerticalAlignment>Center</VerticalAlignment>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="DisabledOverlay" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.5" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="LinkStates">
                                <VisualState x:Name="ActiveLink">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="ActiveBorder" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <EasingDoubleKeyFrame KeyTime="00:00:00" Value="1" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="ContentBorder" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <EasingDoubleKeyFrame KeyTime="00:00:00" Value="1" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Indicator" d:IsOptimized="True" />
                                        <ColorAnimation To="{StaticResource NavigationActiveForegroundColor}" BeginTime="00:00:00" Duration="00:00:00" Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="(UIElement.Foreground).(SolidColorBrush.Color)" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="InactiveLink" />
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="0.35" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="(Rectangle.RadiusX)">
                                            <EasingDoubleKeyFrame KeyTime="00:00:00" Value="1" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="(Rectangle.RadiusY)">
                                            <EasingDoubleKeyFrame KeyTime="00:00:00" Value="1" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unfocused" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Path x:Name="Indicator" Width="15" Height="9" Stretch="Fill" Data="M0,0 L1,0 L0.5,1 Z" Fill="{StaticResource ColorAccentSolidBrush}" VerticalAlignment="Bottom" Margin="0,0,0,0" Effect="{StaticResource ControlShadowEffect}" Opacity="0" />
                        <Grid Margin="0,0,0,9">
                            <Rectangle x:Name="FocusVisualElement" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="2" Opacity="0" Margin="-1" RadiusX="1" RadiusY="1" />
                            <Border x:Name="InteractiveBorder" MinWidth="{TemplateBinding MinWidth}" MinHeight="{TemplateBinding MinHeight}" Background="{StaticResource StaticControlBackgroundOver}" Opacity="0" />
                            <Border x:Name="InteractiveElementBorder" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Visibility="Collapsed" />
                            <Border x:Name="ActiveBorder" MinWidth="{TemplateBinding MinWidth}" MinHeight="{TemplateBinding MinHeight}" Background="{StaticResource InputSelectionBrush}" Opacity="0" />
                            <TextBlock x:Name="DisabledOverlay" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}" Text="{TemplateBinding Content}" Foreground="Purple" Visibility="Collapsed" />
                            <Border x:Name="ContentBorder" MinWidth="{TemplateBinding MinWidth}" MinHeight="{TemplateBinding MinHeight}" Opacity="1" BorderBrush="Transparent" BorderThickness="0.5,0" />
                            <ContentControl x:Name="ContentPresenter" FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Opacity="1" />
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--DividerStyle-->
    <Style x:Key="DividerStyle" TargetType="Rectangle">
        <Setter Property="Visibility" Value="Collapsed" />
    </Style>

    <!--
    ***************************************************************************
    Style Updates for Nav Template
    ***************************************************************************
    -->

    <!--NavBrandingStackPanelStyle-->
    <Style x:Key="NavBrandingStackPanelStyle" TargetType="StackPanel">
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="Orientation" Value="Horizontal" />
    </Style>

    <!--LogoIcon-->
    <Style x:Key="NavLogoIcon" TargetType="ContentControl" BasedOn="{StaticResource LogoIcon}">
        <Setter Property="FontSize" Value="12" />
        <Setter Property="Foreground" Value="{StaticResource NavigationInactiveForegroundColorBrush}" />
        <Setter Property="Margin" Value="8,0,0,2" />
    </Style>

    <!--NavContentBorderStyle-->
    <Style x:Key="NavContentBorderStyle" TargetType="Border" BasedOn="{StaticResource ContentBorderStyle}">
        <Setter Property="Margin" Value="0" />
    </Style>

    <!--NavContentFrameStyle-->
    <Style x:Key="NavContentFrameStyle" TargetType="navigation:Frame" BasedOn="{StaticResource ContentFrameStyle}">
        <Setter Property="UriMapper">
            <Setter.Value>
                <uriMapper:UriMapper>
                    <uriMapper:UriMapping MappedUri="/Views/Home.xaml" Uri="" />
                    <uriMapper:UriMapping MappedUri="/Views/{pageName}.xaml" Uri="/{pageName}" />
                    <uriMapper:UriMapping MappedUri="/Views/{pageName}.xaml" Uri="{}{pageName}" />
                </uriMapper:UriMapper>
            </Setter.Value>
        </Setter>
    </Style>

    <!--NavBrandingBorderStyle-->
    <Style x:Key="NavBrandingBorderStyle" TargetType="Border">
        <Setter Property="Margin" Value="0" />
        <Setter Property="VerticalAlignment" Value="Top" />
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="Padding" Value="0,5,0,0" />
    </Style>

    <!--NavLinksBorderStyle-->
    <Style x:Key="NavLinksBorderStyle" TargetType="Border" BasedOn="{StaticResource LinksBorderStyle}">
        <Setter Property="Margin" Value="0" />
    </Style>

    <!--
    ***************************************************************************
    Content Page Styles
    ***************************************************************************
    -->

    <!--PageStyle-->
    <Style x:Key="PageStyle" TargetType="navigation:Page" />

    <!--PageScrollViewerStyle-->
    <Style x:Key="PageScrollViewerStyle" TargetType="ScrollViewer">
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="BorderThickness" Value="0,1,0,1" />
        <Setter Property="Margin" Value="-58,-15,-58,-15" />
        <Setter Property="Padding" Value="58,0,58,0" />
        <Setter Property="VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="HorizontalScrollBarVisibility" Value="Auto" />
    </Style>

    <!--ContentPanelStyle-->
    <Style x:Key="ContentPanelStyle" TargetType="StackPanel" />

    <!--HeaderTextStyle-->
    <Style x:Key="HeaderTextStyle" TargetType="TextBlock">
        <Setter Property="Foreground" Value="{StaticResource NavigationForegroundColorBrush}" />
        <Setter Property="FontFamily" Value="{StaticResource HeadingFontFamily}" />
        <Setter Property="FontSize" Value="{StaticResource Heading1FontSize}" />
        <Setter Property="FontWeight" Value="Bold" />
        <Setter Property="TextWrapping" Value="Wrap" />
        <Setter Property="Margin" Value="0,15,0,40" />
        <Setter Property="HorizontalAlignment" Value="Left" />
    </Style>

    <!--ContentTextStyle-->
    <Style x:Key="ContentTextStyle" TargetType="TextBlock">
        <Setter Property="Foreground" Value="{StaticResource NavigationForegroundColorBrush}" />
        <Setter Property="FontFamily" Value="{StaticResource ContentFontFamily}" />
        <Setter Property="FontSize" Value="{StaticResource ContentFontSize}" />
        <Setter Property="TextWrapping" Value="Wrap" />
        <Setter Property="Margin" Value="0,2,0,2" />
        <Setter Property="HorizontalAlignment" Value="Left" />
    </Style>

    <!--PageHyperlinkButtonStyle-->
    <Style x:Key="PageHyperlinkButtonStyle" TargetType="HyperlinkButton">
        <Setter Property="TargetName" Value="_new" />
        <Setter Property="FontSize" Value="{StaticResource DefaultFontSize}" />
        <Setter Property="VerticalAlignment" Value="Center" />
    </Style>

</ResourceDictionary>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
Software Developer (Senior) http://ADefWebserver.com
United States United States
Michael Washington is a Microsoft MVP. He is a ASP.NET and
C# programmer.
He is the founder of
AiHelpWebsite.com,
LightSwitchHelpWebsite.com, and
HoloLensHelpWebsite.com.

He has a son, Zachary and resides in Los Angeles with his wife Valerie.

He is the Author of:

Comments and Discussions