Click here to Skip to main content
15,895,667 members
Articles / Web Development / ASP.NET

A Silverlight Expense Report Module using View Model (MVVM)

Rate me:
Please Sign up or sign in to vote.
4.82/5 (18 votes)
30 Aug 2010Ms-PL6 min read 64.9K   2.5K   58  
This module allows you to easily gather, and process Expense Reports, from users in your DotNetNuke portal
  • expense_reports.zip
  • expense_reportssilverlightsource.zip
    • 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.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.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
        • ExpenseReports.dll
        • ExpenseReports.pdb
        • ExpenseReports.xap
        • ExpenseReportsTestPage.html
        • 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.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.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.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.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.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.DataVisualization.Toolkit.dll
        • System.Windows.Controls.DataVisualization.Toolkit.pdb
        • System.Windows.Controls.DataVisualization.Toolkit.xml
        • System.Windows.Controls.dll
        • System.Windows.Controls.Input.dll
        • System.Windows.Controls.Input.xml
        • System.Windows.Controls.Toolkit.dll
        • System.Windows.Controls.Toolkit.Internals.dll
        • System.Windows.Controls.Toolkit.pdb
        • System.Windows.Controls.Toolkit.xml
        • System.Windows.Controls.xml
        • System.Windows.Data.dll
        • System.Windows.Data.xml
        • System.Windows.Interactivity.dll
        • System.Windows.Interactivity.xml
        • 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
        • 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.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.resources.dll
          • System.Windows.Data.resources.dll
      • Release
    • Classes
    • DataStore
    • ExpenseReports.csproj
    • ExpenseReports.csproj.user
    • Models
    • obj
    • Properties
    • SampleData
    • Service References
      • wsExpenseReports
        • configuration.svcinfo
        • configuration91.svcinfo
        • ExpenseReports.wsExpenseReports.DeleteReportDetailResponse.datasource
        • ExpenseReports.wsExpenseReports.DeleteReportResponse.datasource
        • ExpenseReports.wsExpenseReports.GetReportDetailsResponse.datasource
        • ExpenseReports.wsExpenseReports.GetReportResponse.datasource
        • ExpenseReports.wsExpenseReports.GetReportsResponse.datasource
        • ExpenseReports.wsExpenseReports.InsertReportDetailResponse.datasource
        • ExpenseReports.wsExpenseReports.InsertReportResponse.datasource
        • ExpenseReports.wsExpenseReports.UpdateReportResponse.datasource
        • Reference.cs
        • Reference.svcmap
        • WebService.disco
        • WebService.wsdl
    • ServiceReferences.ClientConfig
    • ViewModels
    • Views
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls">
    
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Parameters.xaml"/>
        <ResourceDictionary Source="Brushes.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <!--validation template-->
    <ControlTemplate x:Key="ValidationToolTipTemplate">
        <Grid x:Name="Root" RenderTransformOrigin="0,0" Opacity="0" Background="Transparent">
            <Grid.Effect>
                <DropShadowEffect  BlurRadius="3" Direction="-45" Color="Black" Opacity="0.8" ShadowDepth="2"/>
            </Grid.Effect>
            <Grid.RenderTransform>
                <TranslateTransform x:Name="xform" X="-25"/>
            </Grid.RenderTransform>
            
            <vsm:VisualStateManager.VisualStateGroups>
                <vsm:VisualStateGroup Name="OpenStates">
                    <vsm:VisualStateGroup.Transitions>
                        <vsm:VisualTransition GeneratedDuration="0"/>
                        <vsm:VisualTransition To="Open" GeneratedDuration="0:0:0.2">
                            <Storyboard>
                                <DoubleAnimation Storyboard.TargetName="xform" 
                                                 Storyboard.TargetProperty="X" To="0" 
                                                 Duration="0:0:0.2">
                                    <DoubleAnimation.EasingFunction>
                                        <BackEase Amplitude=".3" EasingMode="EaseOut"/>
                                    </DoubleAnimation.EasingFunction>
                                </DoubleAnimation>
                                <DoubleAnimation Storyboard.TargetName="Root"
                                                 Storyboard.TargetProperty="Opacity" To="1" 
                                                 Duration="0:0:0.2"/>
                            </Storyboard>
                        </vsm:VisualTransition>
                    </vsm:VisualStateGroup.Transitions>
                    <vsm:VisualState x:Name="Closed">
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="0" Duration="0"/>
                        </Storyboard>
                    </vsm:VisualState>
                    <vsm:VisualState x:Name="Open">
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="xform" Storyboard.TargetProperty="X" To="0" Duration="0"/>
                            <DoubleAnimation Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="1" Duration="0"/>
                        </Storyboard>
                    </vsm:VisualState>
                </vsm:VisualStateGroup>
            </vsm:VisualStateManager.VisualStateGroups>

            <Path Data="M0,5 L7,10 L7,0 z" Fill="{StaticResource Brush8}" 
                              HorizontalAlignment="Left" VerticalAlignment="Top"
                              Margin="-7 15 0 0" />
            
            <Border CornerRadius="3" Background="{StaticResource Brush8}" MinHeight="30">
                <ContentPresenter/>
            </Border>
        </Grid>
    </ControlTemplate>

    <!--scrollviewer-->
    <Style TargetType="ScrollViewer">
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="VerticalContentAlignment" Value="Top" />
        <Setter Property="VerticalScrollBarVisibility" Value="Visible" />
        <Setter Property="HorizontalScrollBarVisibility" Value="Auto" />
        <Setter Property="Padding" Value="0"/>
        <Setter Property="BorderBrush" Value="{x:Null}"/>
        <Setter Property="Background" Value="{x:Null}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ScrollViewer">
                    <Border BorderBrush="{TemplateBinding BorderBrush}" 
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid Background="{TemplateBinding Background}">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>

                            <ScrollContentPresenter x:Name="ScrollContentPresenter"
                                                  Cursor="{TemplateBinding Cursor}"
                                                  Margin="{TemplateBinding Padding}"
                                                  ContentTemplate="{TemplateBinding ContentTemplate}"/>

                            <Rectangle Grid.Column="1" Grid.Row="1" Fill="{StaticResource Brush1}"/>

                            <ScrollBar x:Name="VerticalScrollBar" Width="18"
                                     IsTabStop="False"
                                     Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                                     Grid.Column="1" Grid.Row="0" Orientation="Vertical"
                                     ViewportSize="{TemplateBinding ViewportHeight}"
                                     Maximum="{TemplateBinding ScrollableHeight}"
                                     Minimum="0"
                                     Value="{TemplateBinding VerticalOffset}"/>

                            <ScrollBar x:Name="HorizontalScrollBar" Height="18"
                                     IsTabStop="False"
                                     Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                                     Grid.Column="0" Grid.Row="1" Orientation="Horizontal"
                                     ViewportSize="{TemplateBinding ViewportWidth}"
                                     Maximum="{TemplateBinding ScrollableWidth}"
                                     Minimum="0"
                                     Value="{TemplateBinding HorizontalOffset}"/>

                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!--textblock-->
    <Style TargetType="TextBlock">
        <Setter Property="Foreground" Value="{StaticResource Brush2}"/>
        <Setter Property="FontFamily" Value="{StaticResource FontFamily1}"/>
        <Setter Property="FontSize" Value="{StaticResource FontSize1}"/>
    </Style>

    <!--textbox-->
    <Style x:Key="TextBoxBase" TargetType="TextBox">
        <Setter Property="FontFamily" Value="{StaticResource FontFamily1}"/>
        <Setter Property="FontSize" Value="{StaticResource FontSize1}"/>
        <Setter Property="CaretBrush" Value="#303030"/>
        <Setter Property="SelectionBackground" Value="{StaticResource Brush2}"/>
        <Setter Property="SelectionForeground" Value="{StaticResource Brush5}"/>
        <Setter Property="BorderThickness" Value="2"/>
        <Setter Property="Background" Value="{StaticResource Brush5}"/>
        <Setter Property="Foreground" Value="{StaticResource Brush2}"/>
        <Setter Property="Padding" Value="4"/>
        <Setter Property="BorderBrush" Value="{StaticResource Brush4}"/>
        <Setter Property="Height" Value="{StaticResource Height1}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TextBox">
                    <Grid x:Name="RootElement">
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualState x:Name="Normal"/>
                                <vsm:VisualState x:Name="MouseOver">

                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Border"
                                                         Storyboard.TargetProperty="Opacity"
                                                         BeginTime="0"
                                                         To="{StaticResource OpacityDisable}" Duration="0:0:0.0"/>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="ReadOnly">

                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                            <vsm:VisualStateGroup x:Name="FocusStates">
                                <vsm:VisualState x:Name="Focused">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="FocusBorder"
                                                         Storyboard.TargetProperty="Opacity"
                                                         BeginTime="0"
                                                         To="1" Duration="0:0:0.0"/>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Unfocused">

                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                            <vsm:VisualStateGroup x:Name="ValidationStates">
                                <vsm:VisualState x:Name="Valid"/>
                                <vsm:VisualState x:Name="InvalidUnfocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border"
                                                                       Storyboard.TargetProperty="BorderBrush">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource Brush8}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="validationTooltip"
                                                                       Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="InvalidFocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border"
                                                                       Storyboard.TargetProperty="BorderBrush">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource Brush8}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="validationTooltip"
                                                                       Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>

                        <Border x:Name="Border" Background="{TemplateBinding Background}" 
                                BorderThickness="{TemplateBinding BorderThickness}"
                                BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="4"/>

                        <Border x:Name="FocusBorder" BorderThickness="1" BorderBrush="{StaticResource Brush7}"
                                Margin="2" CornerRadius="2" Opacity="0"/>

                        <ScrollViewer x:Name="ContentElement" Margin="{TemplateBinding Padding}" 
                                      BorderThickness="0" IsTabStop="False" VerticalAlignment="Top"
                                      HorizontalAlignment="Stretch"/>
                        <ToolTipService.ToolTip>
                            <ToolTip x:Name="validationTooltip" Placement="Right" 
                                     VerticalOffset="-10" HorizontalOffset="10" Visibility="Collapsed"
                                         Template="{StaticResource ValidationToolTipTemplate}"
                                         PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                         DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}">
                                <TextBlock UseLayoutRounding="false" 
                                            Foreground="White" Margin="8 4" MaxWidth="150" TextWrapping="Wrap" 
                                            Text="{Binding (Validation.Errors)[0].ErrorContent}"/>
                            </ToolTip>
                        </ToolTipService.ToolTip>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="TextBox" BasedOn="{StaticResource TextBoxBase}"/>

    <!--passwordbox-->
    <Style TargetType="PasswordBox">
        <Setter Property="CaretBrush" Value="{StaticResource CaretColor}"/>
        <Setter Property="SelectionBackground" Value="{StaticResource Brush2}"/>
        <Setter Property="SelectionForeground" Value="{StaticResource Brush5}"/>
        <Setter Property="BorderThickness" Value="2"/>
        <Setter Property="Background" Value="{StaticResource Brush5}"/>
        <Setter Property="Foreground" Value="{StaticResource Brush2}"/>
        <Setter Property="Padding" Value="4"/>
        <Setter Property="BorderBrush" Value="{StaticResource Brush4}"/>
        <Setter Property="Height" Value="{StaticResource Height1}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="PasswordBox">
                    <Grid x:Name="RootElement">
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualState x:Name="Normal"/>
                                <vsm:VisualState x:Name="MouseOver">

                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Border"
                                                         Storyboard.TargetProperty="Opacity"
                                                         BeginTime="0"
                                                         To="{StaticResource OpacityDisable}" Duration="0:0:0.0"/>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="ReadOnly">

                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                            <vsm:VisualStateGroup x:Name="FocusStates">
                                <vsm:VisualState x:Name="Focused">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="FocusBorder"
                                                         Storyboard.TargetProperty="Opacity"
                                                         BeginTime="0"
                                                         To="1" Duration="0:0:0.0"/>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Unfocused">

                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                            <vsm:VisualStateGroup x:Name="ValidationStates">
                                <vsm:VisualState x:Name="Valid"/>
                                <vsm:VisualState x:Name="InvalidUnfocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border"
                                                                       Storyboard.TargetProperty="BorderBrush">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource Brush8}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="validationTooltip"
                                                                       Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="InvalidFocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border"
                                                                       Storyboard.TargetProperty="BorderBrush">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource Brush8}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="validationTooltip"
                                                                       Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>

                        <Border x:Name="Border" Background="{TemplateBinding Background}" 
                                BorderThickness="{TemplateBinding BorderThickness}"
                                BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="4"/>

                        <Border x:Name="FocusBorder" BorderThickness="1" BorderBrush="{StaticResource Brush7}"
                                Margin="2" CornerRadius="2" Opacity="0"/>

                        <Border x:Name="ContentElement" Margin="{TemplateBinding Padding}" 
                                      BorderThickness="0" VerticalAlignment="Center"
                                      HorizontalAlignment="Stretch"/>

                        <ToolTipService.ToolTip>
                            <ToolTip x:Name="validationTooltip" Placement="Right" HorizontalOffset="10" 
                                     VerticalOffset="-10" Visibility="Collapsed"
                                         Template="{StaticResource ValidationToolTipTemplate}"
                                         PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                         DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}">
                                <TextBlock UseLayoutRounding="false" 
                                            Foreground="White" Margin="8 4" MaxWidth="150" TextWrapping="Wrap" 
                                            Text="{Binding (Validation.Errors)[0].ErrorContent}"/>
                            </ToolTip>
                        </ToolTipService.ToolTip>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--hyperlinkbutton-->
    <Style TargetType="HyperlinkButton">
        <Setter Property="Foreground" Value="{StaticResource Brush3}" />
        <Setter Property="FontFamily" Value="{StaticResource FontFamily1}"/>
        <Setter Property="FontSize" Value="{StaticResource FontSize1}"/>
        <Setter Property="Cursor" Value="Hand"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="HyperlinkButton">
                    <Grid Cursor="{TemplateBinding Cursor}" Background="{TemplateBinding Background}">
                        
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualState x:Name="Normal"/>
                                <vsm:VisualState x:Name="MouseOver">
                                    
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="UnderlineTextBlock" 
                                                                       Storyboard.TargetProperty="Visibility" Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="DisabledOverlay" 
                                                                       Storyboard.TargetProperty="Visibility" Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                            <vsm:VisualStateGroup x:Name="FocusStates">
                                <vsm:VisualState x:Name="Focused">
                                    <Storyboard>
                                        <ColorAnimation Storyboard.TargetName="contentPresenter" 
                                                        Storyboard.TargetProperty="(Effect).(DropShadowEffect.Color)" 
                                                        Duration="0" To="Black"/>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Unfocused"/>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>
                        
                        <TextBlock FontFamily="{TemplateBinding FontFamily}"
                                   FontSize="{TemplateBinding FontSize}"
                          x:Name="UnderlineTextBlock"
                          Text="{TemplateBinding Content}"
                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                          Margin="{TemplateBinding Padding}"
                          TextDecorations="Underline"
                          Visibility="Collapsed">
                            <TextBlock.Effect>
                                <DropShadowEffect BlurRadius="0" Color="White" Opacity="0.8" ShadowDepth="1"/>
                            </TextBlock.Effect>
                        </TextBlock>
                        <TextBlock Canvas.ZIndex="1"
                                   FontFamily="{TemplateBinding FontFamily}"
                                   FontSize="{TemplateBinding FontSize}"
                                  x:Name="DisabledOverlay"
                                  Text="{TemplateBinding Content}"
                                  Foreground="{StaticResource Brush9}"
                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                  Margin="{TemplateBinding Padding}"
                                  Visibility="Collapsed">
                            <TextBlock.Effect>
                                <DropShadowEffect BlurRadius="0" Color="White" Opacity="0.8" ShadowDepth="1"/>
                            </TextBlock.Effect>
                        </TextBlock>
                        <ContentPresenter
                          x:Name="contentPresenter"
                          Content="{TemplateBinding Content}"
                          ContentTemplate="{TemplateBinding ContentTemplate}"
                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                          Margin="{TemplateBinding Padding}" >
                            <ContentPresenter.Effect>
                                <DropShadowEffect BlurRadius="0" Color="White" Opacity="0.8" ShadowDepth="1"/>
                            </ContentPresenter.Effect>
                        </ContentPresenter>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!--button-->
    <Style TargetType="Button">
        <Setter Property="Foreground" Value="{StaticResource Brush2}"/>
        <Setter Property="Padding" Value="3 0"/>
        <Setter Property="Height" Value="22"/>
        <Setter Property="FontFamily" Value="{StaticResource FontFamily1}"/>
        <Setter Property="FontSize" Value="{StaticResource FontSize2}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid x:Name="root">
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualState x:Name="Normal">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Hover"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0:0:0.1" To="0"/>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Hover"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0:0:0.1" To="1"/>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Hover"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0:0:0.02" To="0"/>
                                        <DoubleAnimation Storyboard.TargetName="Click"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0:0:0.02" To="1"/>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="root"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0" To="{StaticResource OpacityDisable}"/>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                            <vsm:VisualStateGroup x:Name="FocusStates">
                                <vsm:VisualState x:Name="Focused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Focus"
                                                                       Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Unfocused" />
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>

                        <Border BorderThickness="1" CornerRadius="4" BorderBrush="{StaticResource Brush10}"/>

                        <Border BorderThickness="2" CornerRadius="3" BorderBrush="{StaticResource Brush11}"
                                    Background="{StaticResource Brush12}" Margin="1"/>
                        
                        <Border x:Name="Click" CornerRadius="3" Background="{StaticResource Brush14}" Opacity="0"
                                Margin="1"/>

                        <Border x:Name="Focus" BorderThickness="2" CornerRadius="3" 
                                BorderBrush="{StaticResource Brush15}" Margin="1" Visibility="Collapsed"/>
                        
                        <Border x:Name="Hover" Background="{StaticResource Brush13}" Opacity="0"/>

                        <ContentPresenter
                                      x:Name="contentPresenter"
                                      Content="{TemplateBinding Content}"
                                      ContentTemplate="{TemplateBinding ContentTemplate}"
                                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                      HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                      Margin="{TemplateBinding Padding}"/>

                        

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--repeatbutton-->
    <Style TargetType="RepeatButton">
        <Setter Property="Padding" Value="3 0"/>
        <Setter Property="Height" Value="22"/>
        <Setter Property="FontFamily" Value="{StaticResource FontFamily1}"/>
        <Setter Property="FontSize" Value="{StaticResource FontSize2}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="RepeatButton">
                    <Grid x:Name="root">
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualState x:Name="Normal">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Hover"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0:0:0.1" To="0"/>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Hover"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0:0:0.1" To="1"/>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Hover"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0:0:0.02" To="0"/>
                                        <DoubleAnimation Storyboard.TargetName="Click"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0:0:0.02" To="1"/>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="root"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0" To="{StaticResource OpacityDisable}"/>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                            <vsm:VisualStateGroup x:Name="FocusStates">
                                <vsm:VisualState x:Name="Focused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Focus"
                                                                       Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Unfocused" />
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>

                        <Border BorderThickness="1" CornerRadius="4" BorderBrush="{StaticResource Brush10}"/>

                        <Border BorderThickness="2" CornerRadius="3" BorderBrush="{StaticResource Brush11}"
                                    Background="{StaticResource Brush12}" Margin="1"/>

                        <Border x:Name="Click" CornerRadius="3" Background="{StaticResource Brush14}" Opacity="0"
                                Margin="1"/>

                        <Border x:Name="Focus" BorderThickness="2" CornerRadius="3" 
                                BorderBrush="{StaticResource Brush15}" Margin="1" Visibility="Collapsed"/>

                        <Border x:Name="Hover" Background="{StaticResource Brush13}" Opacity="0"/>

                        <ContentPresenter
                                      x:Name="contentPresenter"
                                      Content="{TemplateBinding Content}"
                                      ContentTemplate="{TemplateBinding ContentTemplate}"
                                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                      HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                      Margin="{TemplateBinding Padding}"/>



                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--togglebutton-->
    <Style x:Key="ToggleButtonBase" TargetType="ToggleButton">
        <Setter Property="Padding" Value="3 0"/>
        <Setter Property="Height" Value="22"/>
        <Setter Property="FontFamily" Value="{StaticResource FontFamily1}"/>
        <Setter Property="FontSize" Value="{StaticResource FontSize2}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToggleButton">
                    <Grid x:Name="root">
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualState x:Name="Normal">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Hover"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0:0:0.1" To="0"/>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Hover"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0:0:0.1" To="1"/>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Hover"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0:0:0.02" To="0"/>
                                        <DoubleAnimation Storyboard.TargetName="Click"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0:0:0.02" To="1"/>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="root"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0" To="{StaticResource OpacityDisable}"/>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                            
                            <vsm:VisualStateGroup x:Name="CheckStates">
                                <vsm:VisualState x:Name="Checked">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Background"
                                                         Storyboard.TargetProperty="(Background).(LinearGradientBrush.GradientStops)[3].(GradientStop.Offset)"
                                                         Duration="0" To="0.05"/>
                                        <ColorAnimation Storyboard.TargetName="Background"
                                                         Storyboard.TargetProperty="(Background).(LinearGradientBrush.GradientStops)[1].(GradientStop.Color)"
                                                         Duration="0" To="#FFFBFBFB"/>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Unchecked"/>
                            </vsm:VisualStateGroup>

                            <vsm:VisualStateGroup x:Name="FocusStates">
                                <vsm:VisualState x:Name="Focused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Focus"
                                                                       Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Unfocused" />
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>

                        <Border BorderThickness="1" CornerRadius="4" BorderBrush="{StaticResource Brush10}"/>

                        <Border x:Name="Background" BorderThickness="2" CornerRadius="3" BorderBrush="{StaticResource Brush11}"
                                    Background="{StaticResource Brush12}" Margin="1"/>

                        <Border x:Name="Click" CornerRadius="3" Background="{StaticResource Brush14}" Opacity="0"
                                Margin="1"/>

                        <Border x:Name="Focus" BorderThickness="2" CornerRadius="3" 
                                BorderBrush="{StaticResource Brush15}" Margin="1" Visibility="Collapsed"/>

                        <Border x:Name="Hover" Background="{StaticResource Brush13}" Opacity="0"/>

                        <ContentPresenter
                                      x:Name="contentPresenter"
                                      Content="{TemplateBinding Content}"
                                      ContentTemplate="{TemplateBinding ContentTemplate}"
                                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                      HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                      Margin="{TemplateBinding Padding}"/>



                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="ToggleButton" BasedOn="{StaticResource ToggleButtonBase}"/>
    
    <!--checkbox-->
    <Style TargetType="CheckBox">
        <Setter Property="BorderBrush" Value="{StaticResource Brush4}"/>
        <Setter Property="Background" Value="{StaticResource Brush5}"/>
        <Setter Property="Foreground" Value="{StaticResource Brush2}"/>
        <Setter Property="BorderThickness" Value="2"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="FontFamily" Value="{StaticResource FontFamily1}"/>
        <Setter Property="FontSize" Value="{StaticResource FontSize2}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="CheckBox">
                    <Grid x:Name="root">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="16"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualState x:Name="Normal"/>
                                <vsm:VisualState x:Name="MouseOver">
                                   
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Pressed">
                                    
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="root"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0" To="{StaticResource OpacityDisable}"/>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                            <vsm:VisualStateGroup x:Name="CheckStates">
                                <vsm:VisualState x:Name="Checked">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="CheckIcon" 
                                                         Storyboard.TargetProperty="(UIElement.Opacity)" 
                                                         Duration="0" To="1"/>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Unchecked"/>
                                <vsm:VisualState x:Name="Indeterminate">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="IndeterminateIcon" 
                                                         Storyboard.TargetProperty="(UIElement.Opacity)" Duration="0" To="1"/>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                            <vsm:VisualStateGroup x:Name="FocusStates">
                                <vsm:VisualState x:Name="Focused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Focus"
                                                                       Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Unfocused" />
                            </vsm:VisualStateGroup>
                            <vsm:VisualStateGroup x:Name="ValidationStates">
                                <vsm:VisualState x:Name="Valid"/>
                                <vsm:VisualState x:Name="InvalidUnfocused">
                                    
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="InvalidFocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="validationTooltip" 
                                                                       Storyboard.TargetProperty="IsOpen">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="true"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>
                        
                        <Grid >

                            <Border x:Name="Border" Background="{TemplateBinding Background}" 
                                BorderThickness="{TemplateBinding BorderThickness}"
                                BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="4"/>
                            <Border x:Name="Focus" BorderThickness="2" CornerRadius="4" 
                                BorderBrush="{StaticResource Brush15}" Margin="-1" Visibility="Collapsed"/>

                            <Path x:Name="CheckIcon" Margin="1,1,0,1.5" Fill="{StaticResource Brush2}" Stretch="Fill" Opacity="0" Width="10.5" Height="10" Data="M102.03442,598.79645 L105.22962,597.78918 L106.78825,600.42358 C106.78825,600.42358 108.51028,595.74304 110.21724,593.60419 C112.00967,591.35822 114.89314,591.42316 114.89314,591.42316 C114.89314,591.42316 112.67844,593.42645 111.93174,594.44464 C110.7449,596.06293 107.15683,604.13837 107.15683,604.13837 z" FlowDirection="LeftToRight"/>
                            <Rectangle x:Name="IndeterminateIcon" Height="2" Fill="{StaticResource Brush2}" Opacity="0" Width="6"/>

                            <ToolTipService.ToolTip>
                                <ToolTip x:Name="validationTooltip" 
                                       Template="{StaticResource ValidationToolTipTemplate}"
                                       DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                       Placement="Right" 
                                       PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}">
                                    <ToolTip.Triggers>
                                        <EventTrigger RoutedEvent="Canvas.Loaded">
                                            <EventTrigger.Actions>
                                                <BeginStoryboard>
                                                    <Storyboard>
                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="validationTooltip" 
                                                                                       Storyboard.TargetProperty="IsHitTestVisible">
                                                            <DiscreteObjectKeyFrame KeyTime="0" Value="true"/>
                                                        </ObjectAnimationUsingKeyFrames>
                                                    </Storyboard>
                                                </BeginStoryboard>
                                            </EventTrigger.Actions>
                                        </EventTrigger>
                                    </ToolTip.Triggers>
                                </ToolTip>
                            </ToolTipService.ToolTip>
                            
                        </Grid>
                        
                        <ContentPresenter
                              Grid.Column="1"
                              x:Name="contentPresenter"
                              Content="{TemplateBinding Content}"
                              ContentTemplate="{TemplateBinding ContentTemplate}"
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                              Margin="{TemplateBinding Padding}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--radiobutton-->
    <Style TargetType="RadioButton">
        <Setter Property="BorderBrush" Value="{StaticResource Brush4}"/>
        <Setter Property="Background" Value="{StaticResource Brush5}"/>
        <Setter Property="Foreground" Value="{StaticResource Brush2}"/>
        <Setter Property="BorderThickness" Value="2"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="FontFamily" Value="{StaticResource FontFamily1}"/>
        <Setter Property="FontSize" Value="{StaticResource FontSize2}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="RadioButton">
                    <Grid x:Name="root">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualState x:Name="Normal"/>
                                <vsm:VisualState x:Name="MouseOver">

                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Pressed">

                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="root"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0" To="{StaticResource OpacityDisable}"/>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                            <vsm:VisualStateGroup x:Name="CheckStates">
                                <vsm:VisualState x:Name="Checked">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="CheckIcon" 
                                                         Storyboard.TargetProperty="(UIElement.Opacity)" 
                                                         Duration="0" To="1"/>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Unchecked"/>
                            </vsm:VisualStateGroup>
                            <vsm:VisualStateGroup x:Name="FocusStates">
                                <vsm:VisualState x:Name="Focused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Focus"
                                                                       Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Unfocused" />
                            </vsm:VisualStateGroup>
                            <vsm:VisualStateGroup x:Name="ValidationStates">
                                <vsm:VisualState x:Name="Valid"/>
                                <vsm:VisualState x:Name="InvalidUnfocused">

                                </vsm:VisualState>
                                <vsm:VisualState x:Name="InvalidFocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="validationTooltip" 
                                                                       Storyboard.TargetProperty="IsOpen">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="true"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>

                        <Grid Width="16" Height="16">

                            <Ellipse x:Name="Border" Fill="{TemplateBinding Background}" 
                                StrokeThickness="2"
                                Stroke="{TemplateBinding BorderBrush}"/>
                            
                            <Ellipse x:Name="Focus" StrokeThickness="2" 
                                Stroke="{StaticResource Brush15}" Margin="-1" Visibility="Collapsed"/>

                            <Ellipse x:Name="CheckIcon" Margin="4" Fill="{StaticResource Brush2}" Stretch="Fill" Opacity="0" />

                            <ToolTipService.ToolTip>
                                <ToolTip x:Name="validationTooltip" 
                                       Template="{StaticResource ValidationToolTipTemplate}"
                                       DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                       Placement="Right" 
                                       PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}">
                                    <ToolTip.Triggers>
                                        <EventTrigger RoutedEvent="Canvas.Loaded">
                                            <EventTrigger.Actions>
                                                <BeginStoryboard>
                                                    <Storyboard>
                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="validationTooltip" 
                                                                                       Storyboard.TargetProperty="IsHitTestVisible">
                                                            <DiscreteObjectKeyFrame KeyTime="0" Value="true"/>
                                                        </ObjectAnimationUsingKeyFrames>
                                                    </Storyboard>
                                                </BeginStoryboard>
                                            </EventTrigger.Actions>
                                        </EventTrigger>
                                    </ToolTip.Triggers>
                                </ToolTip>
                            </ToolTipService.ToolTip>

                        </Grid>

                        <ContentPresenter
                              Grid.Column="1"
                              x:Name="contentPresenter"
                              Content="{TemplateBinding Content}"
                              ContentTemplate="{TemplateBinding ContentTemplate}"
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                              Margin="{TemplateBinding Padding}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!--slider-->
    <Style TargetType="Slider">
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Maximum" Value="10" />
        <Setter Property="Minimum" Value="0" />
        <Setter Property="Value" Value="0" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Slider">
                    <Grid x:Name="Root">
                        <Grid.Resources>
                            <ControlTemplate x:Key="RepeatButtonTemplate">
                                <Grid x:Name="Root" Opacity="0" Background="Transparent"/>
                            </ControlTemplate>
                        </Grid.Resources>
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualState x:Name="Normal"/>
                                <vsm:VisualState x:Name="MouseOver"/>
                                <vsm:VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Root"
                                                         Storyboard.TargetProperty="Opacity"
                                                         BeginTime="0"
                                                         To="{StaticResource OpacityDisable}" Duration="0:0:0.0"/>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>

                        <Grid x:Name="HorizontalTemplate">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>

                            <Rectangle Fill="{StaticResource Brush4}" Height="2" Grid.ColumnSpan="3"/>
                            <Rectangle Fill="{StaticResource Brush2}" Height="2" Grid.ColumnSpan="2"/>
                            <RepeatButton x:Name="HorizontalTrackLargeChangeDecreaseRepeatButton" Height="14" IsTabStop="False" Template="{StaticResource RepeatButtonTemplate}" Grid.Column="0"/>
                            <Thumb Height="14" x:Name="HorizontalThumb" Width="14" Grid.Column="1" IsTabStop="True"/>
                            <RepeatButton x:Name="HorizontalTrackLargeChangeIncreaseRepeatButton" Height="14" IsTabStop="False" Template="{StaticResource RepeatButtonTemplate}" Grid.Column="2"/>
                        </Grid>

                        
                        <Grid x:Name="VerticalTemplate" Visibility="Collapsed">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>

                            <Rectangle Fill="{StaticResource Brush4}" Width="2" Grid.RowSpan="3"/>
                            <Rectangle Fill="{StaticResource Brush2}" Width="2" Grid.RowSpan="2" Grid.Row="3"/>
                            <RepeatButton x:Name="VerticalTrackLargeChangeDecreaseRepeatButton" Width="14" IsTabStop="False" Template="{StaticResource RepeatButtonTemplate}" Grid.Row="2"/>
                            <Thumb Height="14" x:Name="VerticalThumb" Width="14" Grid.Row="1" IsTabStop="True"/>
                            <RepeatButton x:Name="VerticalTrackLargeChangeIncreaseRepeatButton" Width="14" IsTabStop="False" Template="{StaticResource RepeatButtonTemplate}" Grid.Row="0"/>
                        </Grid>

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="Thumb">
        <Setter Property="Background" Value="{StaticResource Brush2}"/>
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="BorderBrush" Value="{StaticResource Brush2}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Thumb">
                    <Grid>
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualState x:Name="Normal"/>
                                <vsm:VisualState x:Name="MouseOver">
                                    
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Pressed">
                                    
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Disabled">
                                    
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                            <vsm:VisualStateGroup x:Name="FocusStates">
                                <vsm:VisualState x:Name="Focused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Focus"
                                                                       Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Unfocused"/>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>
                        
                        <Ellipse Stroke="{TemplateBinding BorderBrush}" StrokeThickness="2"
                                 Fill="{StaticResource Brush5}"/>

                        <Ellipse Fill="{TemplateBinding Background}" Margin="4"/>

                        <Ellipse x:Name="Focus" StrokeThickness="2" 
                                Stroke="{StaticResource Brush15}" Margin="-2" Visibility="Collapsed"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--progressbar-->
    <Style TargetType="ProgressBar">
        <Setter Property="Foreground" Value="{StaticResource Brush3}"/>
        <Setter Property="Background" Value="{StaticResource Brush5}" />
        <Setter Property="BorderThickness" Value="2"/>
        <Setter Property="Maximum" Value="100" />
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="BorderBrush" Value="{StaticResource Brush4}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ProgressBar">
                    <Grid x:Name="Root">
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualState x:Name="Determinate"/>
                                <vsm:VisualState x:Name="Indeterminate">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames BeginTime="0" 
                                                                       Storyboard.TargetName="ProgressBarRootGrid"
                                                                       Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames BeginTime="0" 
                                                                       Storyboard.TargetName="ProgressBarIndeterminateRootGrid"
                                                                       Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        
                                        
                                        
                                        <DoubleAnimation Storyboard.TargetName="tr" Storyboard.TargetProperty="X"
                                                         Duration="0:0:2" To="0.8" AutoReverse="True" RepeatBehavior="Forever">
                                            <DoubleAnimation.EasingFunction>
                                                <QuadraticEase EasingMode="EaseInOut"   />
                                            </DoubleAnimation.EasingFunction>
                                        </DoubleAnimation>

                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="gs2" Storyboard.TargetProperty="Offset"
                                                                       BeginTime="0:0:0" Duration="0:0:4"
                                                                       RepeatBehavior="Forever">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="0.1"/>
                                            <DiscreteObjectKeyFrame KeyTime="0:0:2" Value="0"/>
                                        </ObjectAnimationUsingKeyFrames>

                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="gs3" Storyboard.TargetProperty="Offset"
                                                                       BeginTime="0:0:0" Duration="0:0:4"
                                                                       RepeatBehavior="Forever">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="0.2"/>
                                            <DiscreteObjectKeyFrame KeyTime="0:0:2" Value="0.1"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>
                        
                        <Border Name="ProgressBarTrack" CornerRadius="4" 
                                Background="{TemplateBinding Background}" 
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                BorderBrush="{TemplateBinding BorderBrush}" />
                        
                        <Grid x:Name="ProgressBarRootGrid" >
                            <Rectangle HorizontalAlignment="Left" x:Name="ProgressBarIndicator"
                                       Margin="3" RadiusX="3" RadiusY="3" 
                                       Fill="{TemplateBinding Foreground}"/>
                        </Grid>
                        
                        <Grid x:Name="ProgressBarIndeterminateRootGrid" Visibility="Collapsed">
                            <Rectangle Margin="3" RadiusX="3" RadiusY="3" >
                                <Rectangle.Fill>
                                    <LinearGradientBrush StartPoint="0 0.5" EndPoint="1 0.5">
                                        <LinearGradientBrush.RelativeTransform>
                                            <TranslateTransform x:Name="tr" X="0"/>
                                        </LinearGradientBrush.RelativeTransform>
                                        <GradientStop x:Name="gs0" Offset="0" Color="Transparent"/>
                                        <GradientStop x:Name="gs1" Offset="0" Color="Transparent"/>
                                        <GradientStop x:Name="gs2" Offset="0" Color="#CCCCFF"/>
                                        <GradientStop x:Name="gs3" Offset="0.2" Color="#CCCCFF"/>
                                        <GradientStop x:Name="gs4" Offset="0.2" Color="Transparent"/>
                                        <GradientStop x:Name="gs5" Offset="1" Color="Transparent"/>
                                    </LinearGradientBrush>
                                </Rectangle.Fill>
                            </Rectangle>
                        </Grid>
                        
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--combobox-->
    <Style TargetType="ComboBox">
        <Setter Property="Padding" Value="6 2" />
        <Setter Property="Background" Value="{StaticResource Brush5}"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="BorderThickness" Value="2"/>
        <Setter Property="TabNavigation" Value="Once" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="BorderBrush" Value="{StaticResource Brush4}"/>
        <Setter Property="Height" Value="{StaticResource Height1}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ComboBox">
                    <Grid x:Name="root">
                        <Grid.Resources>
                            <Style x:Name="comboToggleStyle" TargetType="ToggleButton">
                                <Setter Property="Foreground" Value="{StaticResource Brush2}"/>
                                <Setter Property="Background" Value="Transparent"/>
                                <Setter Property="Padding" Value="3"/>
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="ToggleButton">
                                            <Grid>
                                                <vsm:VisualStateManager.VisualStateGroups>
                                                    <vsm:VisualStateGroup x:Name="CommonStates">
                                                        <vsm:VisualState x:Name="Normal"/>
                                                        <vsm:VisualState x:Name="MouseOver">
                                                            
                                                        </vsm:VisualState>
                                                        <vsm:VisualState x:Name="Pressed">
                                                            
                                                        </vsm:VisualState>
                                                        <vsm:VisualState x:Name="Disabled" />
                                                    </vsm:VisualStateGroup>
                                                    <vsm:VisualStateGroup x:Name="CheckStates">
                                                        <vsm:VisualState x:Name="Checked">
                                                            
                                                        </vsm:VisualState>
                                                        <vsm:VisualState x:Name="Unchecked"/>
                                                    </vsm:VisualStateGroup>
                                                    <vsm:VisualStateGroup x:Name="FocusStates">
                                                        <vsm:VisualState x:Name="Focused">
                                                            
                                                        </vsm:VisualState>
                                                        <vsm:VisualState x:Name="Unfocused" />
                                                    </vsm:VisualStateGroup>
                                                </vsm:VisualStateManager.VisualStateGroups>

                                                <ContentPresenter
                                                      x:Name="contentPresenter"
                                                      Content="{TemplateBinding Content}"
                                                      ContentTemplate="{TemplateBinding ContentTemplate}"
                                                      HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                      Margin="{TemplateBinding Padding}"/>
                                            </Grid>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </Grid.Resources>
                        
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualState x:Name="Normal" />
                                <vsm:VisualState x:Name="MouseOver" />
                                <vsm:VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="root"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0" To="{StaticResource OpacityDisable}"/>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                            <vsm:VisualStateGroup x:Name="FocusStates">
                                <vsm:VisualState x:Name="Focused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Focus"
                                                                       Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Unfocused"/>
                                <vsm:VisualState x:Name="FocusedDropDown">
                                    
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                            <vsm:VisualStateGroup x:Name="ValidationStates">
                                <vsm:VisualState x:Name="Valid"/>
                                <vsm:VisualState x:Name="InvalidUnfocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ValidationErrorElement" 
                                                                       Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" >
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="InvalidFocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenterBorder"
                                                                       Storyboard.TargetProperty="BorderBrush">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource Brush8}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="validationTooltip"
                                                                       Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>
                        
                        <Border x:Name="ContentPresenterBorder" Background="{TemplateBinding Background}" CornerRadius="4"
                                BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
                            <Grid>
                                <ToggleButton x:Name="DropDownToggle" Style="{StaticResource comboToggleStyle}"  
                                              HorizontalAlignment="Right" VerticalAlignment="Stretch"  Margin="0" 
                                              HorizontalContentAlignment="Center" Background="Transparent" 
                                              BorderThickness="0" Width="16">
                                    <Path x:Name="BtnArrow" Height="4" Width="8" Stretch="Uniform" 
                                          Data="F1 M 301.14,-189.041L 311.57,-189.041L 306.355,-182.942L 301.14,-189.041 Z " 
                                          Margin="0" HorizontalAlignment="Center">
                                        <Path.Fill>
                                            <SolidColorBrush x:Name="BtnArrowColor" Color="#FF333333"/>
                                        </Path.Fill>
                                    </Path>
                                </ToggleButton>
                            </Grid>
                        </Border>
                        
                        <Border x:Name="Focus" BorderThickness="2" CornerRadius="4" 
                                BorderBrush="{StaticResource Brush15}" Margin="1" Visibility="Collapsed"/>

                        <ContentPresenter x:Name="ContentPresenter" 
                                                Margin="{TemplateBinding Padding}"  
                                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                            <TextBlock Text=" "/>
                        </ContentPresenter>
                        
                        <Popup x:Name="Popup">
                            <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}" Margin="0 1 0 0"
                                    CornerRadius="4">
                                <ScrollViewer x:Name="ScrollViewer" BorderThickness="0" Padding="1">
                                    <ItemsPresenter/>
                                </ScrollViewer>
                            </Border>
                            
                        </Popup>

                        <ToolTipService.ToolTip>
                            <ToolTip x:Name="validationTooltip" Placement="Right" 
                                     VerticalOffset="-10" HorizontalOffset="10" Visibility="Collapsed"
                                         Template="{StaticResource ValidationToolTipTemplate}"
                                         PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                         DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}">
                                <TextBlock UseLayoutRounding="false" 
                                            Foreground="White" Margin="8 4" MaxWidth="150" TextWrapping="Wrap" 
                                            Text="{Binding (Validation.Errors)[0].ErrorContent}"/>
                            </ToolTip>
                        </ToolTipService.ToolTip>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--comboboxitem-->
    <Style TargetType="ComboBoxItem">
        <Setter Property="Padding" Value="3"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="TabNavigation" Value="Local"/>
        <Setter Property="Foreground" Value="{StaticResource Brush2}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ComboBoxItem">
                    <Grid Background="{TemplateBinding Background}" x:Name="root">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverBorder"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="0.6" Duration="0:0:0"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="root"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0" To="{StaticResource OpacityDisable}"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="SelectionStates">
                                <VisualState x:Name="Unselected"/>
                                <VisualState x:Name="Selected">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="SelectedBorder"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="1" Duration="0:0:0"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused">
                                    
                                </VisualState>
                                <VisualState x:Name="Unfocused"/>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        
                        <Border x:Name="MouseOverBorder" CornerRadius="4" Background="{StaticResource Brush3}" Opacity="0"/>

                        <Border x:Name="SelectedBorder" BorderThickness="2" CornerRadius="4" 
                                BorderBrush="{StaticResource Brush15}" Opacity="0" Background="{StaticResource Brush3}"/>

                        <ContentControl x:Name="contentPresenter" 
                                        ContentTemplate="{TemplateBinding ContentTemplate}" 
                                        Content="{TemplateBinding Content}" 
                                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                        Margin="{TemplateBinding Padding}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>        
    </Style>

    <!--listbox-->
    <Style TargetType="ListBox">
        <Setter Property="Padding" Value="1"/>
        <Setter Property="Background" Value="{StaticResource Brush5}" />
        <Setter Property="Foreground" Value="{StaticResource Brush2}"/>
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="VerticalContentAlignment" Value="Top" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="BorderThickness" Value="2" />
        <Setter Property="TabNavigation" Value="Once" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="BorderBrush" Value="{StaticResource Brush4}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListBox">
                    <Grid x:Name="root">
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="ValidationStates">
                                <vsm:VisualState x:Name="Valid"/>
                                <vsm:VisualState x:Name="InvalidUnfocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border"
                                                                       Storyboard.TargetProperty="BorderBrush">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource Brush8}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="validationTooltip"
                                                                       Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="InvalidFocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border"
                                                                       Storyboard.TargetProperty="BorderBrush">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource Brush8}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="validationTooltip"
                                                                       Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>

                        <Border x:Name="Border" CornerRadius="4" Background="{TemplateBinding Background}"
			                BorderBrush="{TemplateBinding BorderBrush}"
			                BorderThickness="{TemplateBinding BorderThickness}">
                            <ScrollViewer x:Name="ScrollViewer" Padding="{TemplateBinding Padding}" 
                                          BorderBrush="Transparent" BorderThickness="0" 
                                          TabNavigation="{TemplateBinding TabNavigation}">
                                <ItemsPresenter />
                            </ScrollViewer>
                        </Border>

                        <ToolTipService.ToolTip>
                            <ToolTip x:Name="validationTooltip" Placement="Right" 
                                     VerticalOffset="-10" HorizontalOffset="10" Visibility="Collapsed"
                                         Template="{StaticResource ValidationToolTipTemplate}"
                                         PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                         DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}">
                                <TextBlock UseLayoutRounding="false" 
                                            Foreground="White" Margin="8 4" MaxWidth="150" TextWrapping="Wrap" 
                                            Text="{Binding (Validation.Errors)[0].ErrorContent}"/>
                            </ToolTip>
                        </ToolTipService.ToolTip>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!--listboxitem-->
    <Style TargetType="ListBoxItem">
        <Setter Property="Padding" Value="3"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="TabNavigation" Value="Local"/>
        <Setter Property="Foreground" Value="{StaticResource Brush2}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListBoxItem">
                    <Grid Background="{TemplateBinding Background}" x:Name="root">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverBorder"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="0.6" Duration="0:0:0"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="root"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0" To="{StaticResource OpacityDisable}"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="SelectionStates">
                                <VisualState x:Name="Unselected"/>
                                <VisualState x:Name="Selected">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="SelectedBorder"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="1" Duration="0:0:0"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="SelectedUnfocused">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="SelectedBorder"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="1" Duration="0:0:0"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused">

                                </VisualState>
                                <VisualState x:Name="Unfocused"/>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>

                        <Border x:Name="MouseOverBorder" CornerRadius="4" Background="{StaticResource Brush3}" Opacity="0"/>

                        <Border x:Name="SelectedBorder" BorderThickness="2" CornerRadius="4" 
                                BorderBrush="{StaticResource Brush15}" Opacity="0" Background="{StaticResource Brush3}"/>

                        <ContentControl x:Name="contentPresenter" 
                                        ContentTemplate="{TemplateBinding ContentTemplate}" 
                                        Content="{TemplateBinding Content}" 
                                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                        Margin="{TemplateBinding Padding}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </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