123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <Window x:Class="CustomControls.ChromeWindow"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- WindowStyle="SingleBorderWindow" ResizeMode="CanResize" UseLayoutRounding="True" >
- <Window.Resources>
- <ResourceDictionary>
- <SolidColorBrush x:Key="Border.Foreground" Color="DarkGray"/>
- <SolidColorBrush x:Key="Title.Background" Color="#f3f3f3"/>
- <SolidColorBrush x:Key="Title.Foreground" Color="Black"/>
- <SolidColorBrush x:Key="Button.Static.Foreground" Color="Black"/>
- <SolidColorBrush x:Key="Button.MouseOver.Background" Color="#e9e9e9"/>
- <SolidColorBrush x:Key="Button.MouseOver.Foreground" Color="Black"/>
- <SolidColorBrush x:Key="CloseButton.MouseOver.Background" Color="#c42b1c"/>
- <SolidColorBrush x:Key="CloseButton.MouseOver.Foreground" Color="White"/>
- <!--Base style for title bar buttons-->
- <Style x:Key="CaptionButtonStyle" TargetType="Button">
- <Setter Property="Background" Value="{DynamicResource Button.MouseOver.Background}"/>
- <Setter Property="Foreground" Value="{DynamicResource Button.MouseOver.Foreground}"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="Button">
- <Grid x:Name="LayoutRoot" Background="Transparent" Width="44" Height="30">
- <Path x:Name="path" Width="10" Height="10" Data="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}"
- Stroke="{DynamicResource Button.Static.Foreground}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
- </Grid>
- <ControlTemplate.Triggers>
- <Trigger Property="IsMouseOver" Value="True">
- <Setter TargetName="LayoutRoot" Property="Background" Value="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"/>
- <Setter TargetName="path" Property="Stroke" Value="{Binding Foreground, RelativeSource={RelativeSource TemplatedParent}}"/>
- </Trigger>
- <Trigger Property="IsEnabled" Value="False">
- <Setter TargetName="path" Property="Opacity" Value="0.4"/>
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <!--Minimize-->
- <Style x:Key="MinimizeButtonStyle" TargetType="Button" BasedOn="{StaticResource CaptionButtonStyle}">
- <Setter Property="Content" Value="M0,5.5 L10,5.5"/>
- </Style>
- <!--Maximize-->
- <Style x:Key="MaximizeButtonStyle" TargetType="Button" BasedOn="{StaticResource CaptionButtonStyle}">
- <Setter Property="Content" Value="M0.5,0.5 L9.5,0.5 L9.5,9.5 L0.5,9.5 z"/>
- </Style>
- <!--Restore-->
- <Style x:Key="RestoreButtonStyle" TargetType="Button" BasedOn="{StaticResource CaptionButtonStyle}">
- <Setter Property="Content" Value="M0.5,2.5 L7.5,2.5 L7.5,9.5 L0.5,9.5 z M2.5,0.5 L9.5,0.5 L9.5,7.5"/>
- </Style>
- <!--Close-->
- <Style x:Key="CloseButtonStyle" TargetType="Button" BasedOn="{StaticResource CaptionButtonStyle}">
- <Setter Property="Content" Value="M0.5,0.5 L9.5,9.5 M0.5,9.5 L9.5,0.5"/>
- <Setter Property="Background" Value="{DynamicResource CloseButton.MouseOver.Background}"/>
- <Setter Property="Foreground" Value="{DynamicResource CloseButton.MouseOver.Foreground}"/>
- </Style>
- </ResourceDictionary>
- </Window.Resources>
- <!--Title bar button commands-->
- <Window.CommandBindings>
- <CommandBinding Command="{x:Static SystemCommands.CloseWindowCommand}" CanExecute="CommandBinding_CanExecute" Executed="CommandBinding_Executed_Close" />
- <CommandBinding Command="{x:Static SystemCommands.MaximizeWindowCommand}" CanExecute="CommandBinding_CanExecute" Executed="CommandBinding_Executed_Maximize" />
- <CommandBinding Command="{x:Static SystemCommands.MinimizeWindowCommand}" CanExecute="CommandBinding_CanExecute" Executed="CommandBinding_Executed_Minimize" />
- <CommandBinding Command="{x:Static SystemCommands.RestoreWindowCommand}" CanExecute="CommandBinding_CanExecute" Executed="CommandBinding_Executed_Restore" />
- </Window.CommandBindings>
- <Grid x:Name="parentContainer">
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto"/>
- <RowDefinition Height="*"/>
- </Grid.RowDefinitions>
- <!--App content-->
- <ContentControl Grid.Row="1" x:Name="AppArea"/>
- <!--Window chrome-->
- <Grid x:Name="TitleArea" Grid.Row="0" Height="30" Background="{DynamicResource Title.Background}" MouseLeftButtonDown="TitleArea_MouseDown" MouseMove="TitleArea_MouseMove" MouseUp="TitleArea_MouseUp">
- <DockPanel x:Name="TitleDock" VerticalAlignment="Center" LastChildFill="True">
- <!--App icon-->
- <Image x:Name="TitleIcon" Source="{Binding Icon, RelativeSource={RelativeSource AncestorType={x:Type Window}}}" Margin="8,0,0,0" MaxWidth="16" MaxHeight="16" DockPanel.Dock="Left" VerticalAlignment="Center" MouseDown="TitleIcon_MouseDown" />
- <TextBlock x:Name="TitleText" Text="{Binding Title, RelativeSource={RelativeSource AncestorType={x:Type Window}}}" TextTrimming="CharacterEllipsis" Margin="8,0,0,0" VerticalAlignment="Stretch" Foreground="{DynamicResource Title.Foreground}" />
- </DockPanel>
- <!--Caption buttons-->
- <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
- <Button x:Name="MinimizeButton" Style="{StaticResource MinimizeButtonStyle}" Command="{x:Static SystemCommands.MinimizeWindowCommand}"/>
- <Button x:Name="RestoreButton" Visibility="Collapsed" Style="{StaticResource RestoreButtonStyle}" Command="{x:Static SystemCommands.RestoreWindowCommand}"/>
- <Button x:Name="MaximizeButton" Visibility="Visible" Style="{StaticResource MaximizeButtonStyle}" Command="{x:Static SystemCommands.MaximizeWindowCommand}"/>
- <Button x:Name="CloseButton" Style="{StaticResource CloseButtonStyle}" Command="{x:Static SystemCommands.CloseWindowCommand}"/>
- </StackPanel>
- </Grid>
- <Border x:Name="WindowBorder" BorderThickness="1" BorderBrush="{DynamicResource Border.Foreground}" Grid.RowSpan="2"/>
- <Border x:Name="ResizingBorder" BorderThickness="4" BorderBrush="Transparent" Grid.RowSpan="2" MouseDown="Border_MouseDown" MouseMove="Border_MouseMove" MouseLeave="Border_MouseLeave"/>
- </Grid>
- </Window>
|