123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:sw="clr-namespace:WpfStyleableWindow.StyleableWindow;assembly=MECF.Framework.Common">
- <!--the brushes used in the template (use these to customize the window look along with the window style (see the bottom of this file)-->
- <SolidColorBrush x:Key="WindowColor" Color="Red"/>
- <SolidColorBrush x:Key="WindowBackColor" Color="LightBlue"/>
- <SolidColorBrush x:Key="WindowForeColor" Color="WhiteSmoke"/>
- <SolidColorBrush x:Key="WindowForeHighlightColor" Color="WhiteSmoke"/>
- <SolidColorBrush x:Key="WindowButtonColor" Color="DodgerBlue"/>
- <SolidColorBrush x:Key="WindowButtonOverColor" Color="LightBlue"/>
- <SolidColorBrush x:Key="WindowButtonPressedColor" Color="DarkBlue"/>
- <!---red window brushes-->
- <!--<SolidColorBrush x:Key="WindowColor" Color="DarkRed"/>
- <SolidColorBrush x:Key="WindowBackColor" Color="DarkRed"/>
- <SolidColorBrush x:Key="WindowForeColor" Color="White"/>
- <SolidColorBrush x:Key="WindowForeHighlightColor" Color="White"/>
- <SolidColorBrush x:Key="WindowButtonColor" Color="OrangeRed"/>
- <SolidColorBrush x:Key="WindowButtonOverColor" Color="Orange"/>
- <SolidColorBrush x:Key="WindowButtonPressedColor" Color="DarkOrange"/>-->
- <!--The window template and it's components -->
- <sw:WindowMinimizeCommand x:Key="MinimizeCommand"></sw:WindowMinimizeCommand>
- <sw:WindowMaximizeCommand x:Key="MaximizeCommand"></sw:WindowMaximizeCommand>
- <sw:WindowCloseCommand x:Key="CloseCommand"></sw:WindowCloseCommand>
- <Style TargetType="{x:Type Button}" x:Key="WindowButton">
- <Setter Property="Height" Value="25"/>
- <Setter Property="Width" Value="25"/>
- <Setter Property="Background" Value="{StaticResource WindowButtonColor}"/>
- <Setter Property="Foreground" Value="{StaticResource WindowForeColor}"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type Button}">
- <Border Background="{TemplateBinding Background}">
- <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
- </Border>
- <ControlTemplate.Triggers>
- <Trigger Property="IsEnabled" Value="False">
- <Setter Property="Background" Value="{StaticResource WindowButtonColor}"/>
- <Setter Property="Foreground" Value="{StaticResource WindowColor}"/>
- </Trigger>
- <Trigger Property="IsMouseOver" Value="True">
- <Setter Property="Background" Value="{StaticResource WindowButtonOverColor}"/>
- <Setter Property="Foreground" Value="{StaticResource WindowForeHighlightColor}"/>
- </Trigger>
- <Trigger Property="IsPressed" Value="True">
- <Setter Property="Background" Value="{StaticResource WindowButtonPressedColor}"/>
- <Setter Property="Foreground" Value="{StaticResource WindowForeColor}"/>
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <Style TargetType="{x:Type Image}" x:Key="WindowIcon">
- <Setter Property="Height" Value="25"/>
- <Setter Property="Width" Value="25"/>
- </Style>
- <ControlTemplate x:Key="WindowTemplate" TargetType="{x:Type Window}">
- <Grid Background="{StaticResource WindowBackColor}">
- <Grid>
- <Grid.RowDefinitions>
- <RowDefinition Height="30"/>
- <RowDefinition Height="*"/>
- </Grid.RowDefinitions>
- <Grid Grid.Row="0" Margin="5,0,5,0">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="auto"/>
- <ColumnDefinition Width="*"/>
- <ColumnDefinition Width="75"/>
- </Grid.ColumnDefinitions>
- <Label Grid.Column="0"
- sw:ControlDoubleClickBehavior.ExecuteCommand="{StaticResource CloseCommand}"
- sw:ControlDoubleClickBehavior.ExecuteCommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" Padding="0">
- <Image DockPanel.Dock="Left" Style="{StaticResource WindowIcon}" Source="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}},Path=Icon}"
- Width="16"
- sw:ShowSystemMenuBehavior.TargetWindow="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
- sw:ShowSystemMenuBehavior.LeftButtonShowAt="{Binding ElementName=WindowContent}"/>
- </Label>
- <Label Grid.Column="1" DockPanel.Dock="Left" Content="{TemplateBinding Property=Title}" Padding="3,0,0,0"
- HorizontalContentAlignment="Center"
- VerticalContentAlignment="Center"
- HorizontalAlignment="Stretch"
- VerticalAlignment="Stretch"
- Foreground="{StaticResource WindowForeColor}"
- FontSize="16"
- sw:WindowDragBehavior.LeftMouseButtonDrag="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
- sw:ControlDoubleClickBehavior.ExecuteCommand="{StaticResource MaximizeCommand}"
- sw:ControlDoubleClickBehavior.ExecuteCommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
- sw:ShowSystemMenuBehavior.TargetWindow="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
- sw:ShowSystemMenuBehavior.RightButtonShow="true">
- </Label>
- <StackPanel Grid.Column="2" Orientation="Horizontal">
- <Button DockPanel.Dock="Right" Style="{StaticResource WindowButton}" Command="{StaticResource MinimizeCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}">_</Button>
- <Button DockPanel.Dock="Right" Style="{StaticResource WindowButton}" Command="{StaticResource MaximizeCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}">+</Button>
- <Button DockPanel.Dock="Right" Style="{StaticResource WindowButton}" Command="{StaticResource CloseCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}">X</Button>
- </StackPanel>
- </Grid>
- <Border Grid.Row="1" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
- <Grid>
- <AdornerDecorator>
- <ContentPresenter x:Name="WindowContent"/>
- </AdornerDecorator>
- <ResizeGrip x:Name="WindowResizeGrip" HorizontalAlignment="Right" IsTabStop="false" Visibility="Collapsed" VerticalAlignment="Bottom"/>
- </Grid>
- </Border>
- </Grid>
- <Thumb x:Name="ThumbTop" Height="6" Margin="14,0" VerticalAlignment="Top" Cursor="SizeNS" Opacity="0" sw:WindowResizeBehavior.TopResize="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"/>
- <Thumb x:Name="ThumbTopLeft" Height="6" Width="6" VerticalAlignment="Top" HorizontalAlignment="Left" Cursor="SizeNWSE" Opacity="0" sw:WindowResizeBehavior.TopLeftResize="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"/>
- <Thumb x:Name="ThumbBottom" Height="6" Margin="14,0" VerticalAlignment="Bottom" Cursor="SizeNS" Opacity="0" sw:WindowResizeBehavior.BottomResize="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"/>
- <Thumb x:Name="ThumbTopRight" Height="6" Width="6" VerticalAlignment="Top" HorizontalAlignment="Right" Cursor="SizeNESW" Opacity="0" sw:WindowResizeBehavior.TopRightResize="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"/>
- <Thumb x:Name="ThumbRight" HorizontalAlignment="Right" Margin="0,14" Width="6" Cursor="SizeWE" Opacity="0" sw:WindowResizeBehavior.RightResize="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"/>
- <Thumb x:Name="ThumbBottomRight" Height="6" Width="6" VerticalAlignment="Bottom" HorizontalAlignment="Right" Cursor="SizeNWSE" Opacity="0" sw:WindowResizeBehavior.BottomRightResize="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"/>
- <Thumb x:Name="ThumbLeft" HorizontalAlignment="Left" Margin="0,14" Width="6" Cursor="SizeWE" Opacity="0" sw:WindowResizeBehavior.LeftResize="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"/>
- <Thumb x:Name="ThumbBottomLeft" Height="6" Width="6" VerticalAlignment="Bottom" HorizontalAlignment="Left" Cursor="SizeNESW" Opacity="0" sw:WindowResizeBehavior.BottomLeftResize="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"/>
- </Grid>
- <ControlTemplate.Triggers>
- <MultiTrigger>
- <MultiTrigger.Conditions>
- <Condition Property="ResizeMode" Value="CanResizeWithGrip"/>
- <Condition Property="WindowState" Value="Normal"/>
- </MultiTrigger.Conditions>
- <Setter Property="Visibility" TargetName="WindowResizeGrip" Value="Visible"/>
- </MultiTrigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- <!-- the custom window style and the window template
- Here you can customize the look of the window without having to touch the control template
- or comment out the brushes and create a new style (see the red style below)-->
- <Style x:Key="CustomWindowStyle" TargetType="{x:Type Window}">
- <Setter Property="WindowStyle" Value="None"/>
- <Setter Property="AllowsTransparency" Value="True"/>
- <Setter Property="MinWidth" Value="200"/>
- <Setter Property="MinHeight" Value="46"/>
- <!--CaptionHeight + ResizeBorderThickness * 2-->
- <Setter Property="Background" Value="LightGray"/>
- <Setter Property="BorderBrush" Value="DodgerBlue"/>
- <Setter Property="BorderThickness" Value="2"/>
- <Setter Property="Foreground" Value="Black"/>
-
- <Setter Property="Template" Value="{StaticResource WindowTemplate}"/>
-
- </Style>
- <!--the red style window-->
- <Style x:Key="RedWindowStyle" TargetType="{x:Type Window}">
- <Setter Property="WindowStyle" Value="None"/>
- <Setter Property="AllowsTransparency" Value="True"/>
- <Setter Property="MinWidth" Value="100"/>
- <Setter Property="MinHeight" Value="46"/>
- <Setter Property="Background" Value="white"/>
- <Setter Property="BorderBrush" Value="DarkRed"/>
- <Setter Property="BorderThickness" Value="2"/>
- <Setter Property="Foreground" Value="DarkGray"/>
- <Setter Property="Template" Value="{StaticResource WindowTemplate}"/>
- </Style>
- </ResourceDictionary>
|