WaaaghWindow.xaml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <ResourceDictionary
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:cnvt="clr-namespace:Waaagh.Converters"
  6. xmlns:cc="clr-namespace:Waaagh.CustomControl"
  7. xmlns:helper="clr-namespace:Waaagh.Helpers">
  8. <Style x:Key="TitleButtonStyle" TargetType="Button">
  9. <Setter Property="Margin" Value="1"/>
  10. <Setter Property="BorderThickness" Value="0"/>
  11. <Setter Property="Width" Value="28"/>
  12. <Setter Property="Height" Value="28"/>
  13. <Setter Property="HorizontalContentAlignment" Value="Center"/>
  14. <Setter Property="VerticalContentAlignment" Value="Center"/>
  15. </Style>
  16. <TextBlock x:Key="TestContent" Text="Test"/>
  17. <TextBlock x:Key="TestContent2" Text="Testsds"/>
  18. <Style TargetType="{x:Type cc:WaaaghWindow}">
  19. <Setter Property="WindowChrome.WindowChrome">
  20. <Setter.Value>
  21. <WindowChrome CaptionHeight="32" ResizeBorderThickness="5" UseAeroCaptionButtons="False"/>
  22. </Setter.Value>
  23. </Setter>
  24. <Setter Property="Width" Value="450"/>
  25. <Setter Property="Height" Value="800"/>
  26. <Setter Property="Background" Value="AliceBlue"/>
  27. <Setter Property="Template">
  28. <Setter.Value>
  29. <ControlTemplate TargetType="{x:Type cc:WaaaghWindow}">
  30. <Border x:Name="LayoutRoot" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
  31. <DockPanel>
  32. <Border DockPanel.Dock="Top" Height="28">
  33. <DockPanel LastChildFill="True" Background="Beige">
  34. <!--#region TitleButton-->
  35. <Grid DockPanel.Dock="Right">
  36. <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" WindowChrome.IsHitTestVisibleInChrome="True"
  37. Visibility="{TemplateBinding TitleBarButtons, Converter={cnvt:DefaultContentVisibilityConverter}}">
  38. <Button Style="{StaticResource TitleButtonStyle}" Command="{x:Static SystemCommands.MinimizeWindowCommand}" Content="-"/>
  39. <Button Style="{StaticResource TitleButtonStyle}" Command="{x:Static SystemCommands.MaximizeWindowCommand}" Content="{StaticResource TestContent}"
  40. Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=WindowState, Converter={cnvt:IsCollapsedConverter}, ConverterParameter={x:Static WindowState.Maximized}}"/>
  41. <Button Style="{StaticResource TitleButtonStyle}" Command="{x:Static SystemCommands.RestoreWindowCommand}" Content="{StaticResource TestContent2}"
  42. Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=WindowState, Converter={cnvt:IsCollapsedConverter}, ConverterParameter={x:Static WindowState.Normal}}"/>
  43. <Button Style="{StaticResource TitleButtonStyle}" Command="{x:Static SystemCommands.CloseWindowCommand}" Content="X"/>
  44. </StackPanel>
  45. <ItemsControl ItemsSource="{TemplateBinding TitleBarButtons}" HorizontalAlignment="Right" VerticalAlignment="Center">
  46. <ItemsControl.ItemsPanel>
  47. <ItemsPanelTemplate>
  48. <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" WindowChrome.IsHitTestVisibleInChrome="True"/>
  49. </ItemsPanelTemplate>
  50. </ItemsControl.ItemsPanel>
  51. <ItemsControl.ItemContainerStyle>
  52. <Style TargetType="Button" BasedOn="{StaticResource TitleButtonStyle}"/>
  53. </ItemsControl.ItemContainerStyle>
  54. </ItemsControl>
  55. </Grid>
  56. <!--#endregion-->
  57. <!--#region TitleContent-->
  58. <Border DockPanel.Dock="Left">
  59. <Grid>
  60. <StackPanel Orientation="Horizontal" Visibility="{TemplateBinding TitleBarContent, Converter={cnvt:DefaultContentVisibilityConverter}}">
  61. <Image Source="{TemplateBinding Icon}"/>
  62. <TextBlock Text="{TemplateBinding Title}" VerticalAlignment="Center"/>
  63. </StackPanel>
  64. <ContentPresenter ContentSource="TitleBarContent"/>
  65. </Grid>
  66. </Border>
  67. <!--#endregion-->
  68. </DockPanel>
  69. </Border>
  70. <Border Background="{TemplateBinding Background}">
  71. <AdornerDecorator>
  72. <ContentPresenter/>
  73. </AdornerDecorator>
  74. </Border>
  75. </DockPanel>
  76. </Border>
  77. <ControlTemplate.Triggers>
  78. <Trigger Property="WindowState" Value="Maximized">
  79. <Setter TargetName="LayoutRoot" Property="Margin" Value="{x:Static helper:WindowHelper.ChromeThickness}"/>
  80. </Trigger>
  81. </ControlTemplate.Triggers>
  82. </ControlTemplate>
  83. </Setter.Value>
  84. </Setter>
  85. </Style>
  86. </ResourceDictionary>