Guest User

window style with buttons

a guest
May 10th, 2024
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 9.89 KB | Source Code | 0 0
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2.                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  3.     <Style x:Key="Windows95CaptionButton" TargetType="{x:Type Button}">
  4.  
  5.         <Setter Property="Background" Value="#C3C3C3" />
  6.         <Setter Property="Height" Value="14" />
  7.         <Setter Property="Width" Value="16" />
  8.         <Setter Property="Margin" Value="2,0,0,0" />
  9.  
  10.         <Setter Property="Template">
  11.             <Setter.Value>
  12.                 <ControlTemplate TargetType="Button">
  13.                     <Border BorderThickness="0,0,1,1"
  14.                            BorderBrush="Black"
  15.                            Background="{TemplateBinding Background}"
  16.                            Name="PART_BlackOutline">
  17.                         <Grid>
  18.                             <Border HorizontalAlignment="Stretch"
  19.                                    VerticalAlignment="Stretch"
  20.                                    BorderThickness="1,1,0,0"
  21.                                    BorderBrush="White"
  22.                                    Background="Transparent"
  23.                                    x:Name="PART_WhiteHighlight"/>
  24.  
  25.                             <Border HorizontalAlignment="Stretch"
  26.                                    VerticalAlignment="Stretch"
  27.                                    Margin="1,1,0,0"
  28.                                    BorderThickness="0,0,1,1"
  29.                                    BorderBrush="#828282"
  30.                                    x:Name="PART_DarkerHighlight" />
  31.  
  32.                             <ContentPresenter Content="{TemplateBinding Content}"
  33.                                              HorizontalAlignment="Center"
  34.                                              VerticalAlignment="Center" />
  35.                         </Grid>
  36.                     </Border>
  37.  
  38.                     <ControlTemplate.Triggers>
  39.                         <Trigger Property="IsPressed" Value="True">
  40.                             <Setter TargetName="PART_BlackOutline" Property="BorderBrush" Value="White" />
  41.                             <Setter TargetName="PART_DarkerHighlight" Property="BorderBrush" Value="#DFDFDF" />
  42.                             <Setter TargetName="PART_WhiteHighlight" Property="BorderBrush" Value="Black" />
  43.                             <Setter Property="Background" Value="#C0C0C0" />
  44.                         </Trigger>
  45.                     </ControlTemplate.Triggers>
  46.                 </ControlTemplate>
  47.             </Setter.Value>
  48.         </Setter>
  49.     </Style>
  50.  
  51.     <Style TargetType="Window" x:Key="test">
  52.         <Setter Property="Background" Value="#C3C3C3" />
  53.  
  54.         <Setter Property="WindowChrome.WindowChrome">
  55.             <Setter.Value>
  56.                 <WindowChrome CaptionHeight="0"
  57.                              CornerRadius="0"
  58.                              GlassFrameThickness="-1"
  59.                              ResizeBorderThickness="4"
  60.                              UseAeroCaptionButtons="False" />
  61.             </Setter.Value>
  62.         </Setter>
  63.  
  64.         <Setter Property="Template">
  65.             <Setter.Value>
  66.                 <ControlTemplate TargetType="Window">
  67.                     <Border x:Name="PART_MainBorder"
  68.                            Background="{TemplateBinding Background}"
  69.                            BorderBrush="Black"
  70.                            BorderThickness="0,0,1,1">
  71.                         <Grid>
  72.  
  73.                             <Border HorizontalAlignment="Stretch"
  74.                                    VerticalAlignment="Stretch"
  75.                                    Margin="1"
  76.                                    BorderThickness="1,1,0,0"
  77.                                    BorderBrush="White"
  78.                                    Background="Transparent" />
  79.  
  80.                             <Border HorizontalAlignment="Stretch"
  81.                                    VerticalAlignment="Stretch"
  82.                                    Margin="1,1,0,0"
  83.                                    BorderThickness="0,0,1,1"
  84.                                    BorderBrush="#828282"
  85.                                    Background="Transparent" />
  86.  
  87.                             <Border HorizontalAlignment="Stretch"
  88.                                    VerticalAlignment="Top"
  89.                                    Margin="3,3,3,0"
  90.                                    BorderThickness="0"
  91.                                    BorderBrush="Transparent"
  92.                                    Background="#000082"
  93.                                    Height="18"
  94.                                    x:Name="PART_TitleBar">
  95.                                 <Grid>
  96.                                     <Image HorizontalAlignment="Left"
  97.                                           VerticalAlignment="Center"
  98.                                           Margin="3,0,0,0"
  99.                                           Source="{TemplateBinding Icon}"
  100.                                           RenderOptions.BitmapScalingMode="NearestNeighbor"
  101.                                           Width="16"
  102.                                           Height="16"
  103.                                           x:Name="PART_Icon"/>
  104.                                     <TextBlock HorizontalAlignment="Left"
  105.                                               VerticalAlignment="Center"
  106.                                               Margin="25,0,0,0"
  107.                                               FontFamily="Arial"
  108.                                               Text="{TemplateBinding Title}"
  109.                                               Foreground="White"
  110.                                               FontWeight="SemiBold"
  111.                                               TextOptions.TextFormattingMode="Display"
  112.                                               TextOptions.TextRenderingMode="Aliased"
  113.                                               TextOptions.TextHintingMode="Fixed" />
  114.  
  115.                                     <StackPanel Orientation="Horizontal"
  116.                                                VerticalAlignment="Center"
  117.                                                HorizontalAlignment="Right"
  118.                                                Margin="0,0,2,0">
  119.                                         <Button Style="{StaticResource Windows95CaptionButton}"
  120.                                                x:Name="PART_MinimizeButton">
  121.                                             <Button.Content>
  122.                                                 <Image Height="14"
  123.                                                       Width="16"
  124.                                                       SnapsToDevicePixels="True"
  125.                                                       Source="../Images/close.png" />
  126.                                             </Button.Content>
  127.                                         </Button>
  128.  
  129.                                         <Button Style="{StaticResource Windows95CaptionButton}" Margin="0"
  130.                                                x:Name="PART_MaximizeButton">
  131.                                             <Button.Content>
  132.                                                 <Image Height="14"
  133.                                                       Width="16"
  134.                                                       SnapsToDevicePixels="True"
  135.                                                       Source="../Images/close.png" />
  136.                                             </Button.Content>
  137.                                         </Button>
  138.  
  139.                                         <Button Style="{StaticResource Windows95CaptionButton}"
  140.                                                x:Name="PART_CloseButton">
  141.                                             <Button.Content>
  142.                                                 <Image Height="14"
  143.                                                       Width="16"
  144.                                                       SnapsToDevicePixels="True"
  145.                                                       Source="../Images/close.png" />
  146.                                             </Button.Content>
  147.                                         </Button>
  148.                                     </StackPanel>
  149.                                 </Grid>
  150.                             </Border>
  151.  
  152.                             <ContentPresenter Margin="3,22,2,2"
  153.                                              Content="{TemplateBinding Content}" />
  154.                         </Grid>
  155.                     </Border>
  156.  
  157.                     <ControlTemplate.Triggers>
  158.                         <Trigger Property="ResizeMode" Value="CanMinimize">
  159.                             <Setter TargetName="PART_MaximizeButton" Property="Visibility" Value="Collapsed" />
  160.                         </Trigger>
  161.  
  162.                         <Trigger Property="ResizeMode" Value="NoResize">
  163.                             <Setter TargetName="PART_MaximizeButton" Property="Visibility" Value="Collapsed" />
  164.                             <Setter TargetName="PART_MinimizeButton" Property="Visibility" Value="Collapsed" />
  165.                         </Trigger>
  166.  
  167.                         <Trigger Property="WindowState" Value="Maximized">
  168.                             <Setter TargetName="PART_TitleBar" Property="Margin" Value="10,10,9,0" />
  169.                         </Trigger>
  170.  
  171.                         <Trigger Property="IsActive" Value="False">
  172.                             <Setter TargetName="PART_TitleBar" Property="Background" Value="#808080" />
  173.                         </Trigger>
  174.  
  175.                         <Trigger Property="Icon" Value="{x:Null}">
  176.                             <Setter TargetName="PART_Icon" Property="Visibility" Value="Collapsed" />
  177.                         </Trigger>
  178.                     </ControlTemplate.Triggers>
  179.                 </ControlTemplate>
  180.             </Setter.Value>
  181.         </Setter>
  182.     </Style>
  183. </ResourceDictionary>
Advertisement
Add Comment
Please, Sign In to add comment