WindowsStyle.xaml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <ResourceDictionary
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:prism="http://prismlibrary.com/">
  5. <Style x:Key="WindowStyle" TargetType="{x:Type Window}">
  6. <Setter Property="WindowChrome.WindowChrome">
  7. <Setter.Value>
  8. <WindowChrome
  9. CaptionHeight="32"
  10. CornerRadius="10"
  11. GlassFrameThickness="-1"
  12. ResizeBorderThickness="5"
  13. UseAeroCaptionButtons="False" />
  14. <!-- GlassFrameThickness="-1" win11上显示异常 -->
  15. </Setter.Value>
  16. </Setter>
  17. <Setter Property="Template">
  18. <Setter.Value>
  19. <ControlTemplate TargetType="{x:Type Window}">
  20. <Border
  21. Background="{TemplateBinding Background}"
  22. BorderBrush="{TemplateBinding BorderBrush}"
  23. BorderThickness="{TemplateBinding BorderThickness}">
  24. <AdornerDecorator>
  25. <ContentPresenter x:Name="win_content" />
  26. </AdornerDecorator>
  27. </Border>
  28. <ControlTemplate.Triggers>
  29. <Trigger Property="WindowState" Value="Maximized">
  30. <!-- 调整边框 -->
  31. <Setter TargetName="win_content" Property="Margin" Value="5,5,5,5" />
  32. </Trigger>
  33. </ControlTemplate.Triggers>
  34. </ControlTemplate>
  35. </Setter.Value>
  36. </Setter>
  37. </Style>
  38. <Style x:Key="WindowWithCorderStyle" TargetType="{x:Type Window}">
  39. <Setter Property="WindowChrome.WindowChrome">
  40. <Setter.Value>
  41. <WindowChrome
  42. CaptionHeight="48"
  43. CornerRadius="15"
  44. GlassFrameThickness="-1"
  45. ResizeBorderThickness="5"
  46. UseAeroCaptionButtons="False" />
  47. </Setter.Value>
  48. </Setter>
  49. <Setter Property="Template">
  50. <Setter.Value>
  51. <ControlTemplate TargetType="{x:Type Window}">
  52. <Border
  53. Margin="20"
  54. Background="{TemplateBinding Background}"
  55. BorderBrush="{TemplateBinding BorderBrush}"
  56. BorderThickness="{TemplateBinding BorderThickness}"
  57. CornerRadius="8">
  58. <AdornerDecorator>
  59. <ContentPresenter x:Name="win_content" />
  60. </AdornerDecorator>
  61. </Border>
  62. <ControlTemplate.Triggers>
  63. <Trigger Property="WindowState" Value="Maximized">
  64. <!-- 调整边框 -->
  65. <Setter TargetName="win_content" Property="Margin" Value="5,5,5,5" />
  66. </Trigger>
  67. </ControlTemplate.Triggers>
  68. </ControlTemplate>
  69. </Setter.Value>
  70. </Setter>
  71. </Style>
  72. <!-- 弹窗的窗体样式 -->
  73. <Style
  74. x:Key="DialogWindowStyle"
  75. BasedOn="{StaticResource WindowWithCorderStyle}"
  76. TargetType="{x:Type Window}">
  77. <Setter Property="WindowStyle" Value="None" />
  78. <Setter Property="prism:Dialog.WindowStartupLocation" Value="CenterOwner" />
  79. <Setter Property="SizeToContent" Value="WidthAndHeight" />
  80. <Setter Property="ShowInTaskbar" Value="False" />
  81. <Setter Property="ResizeMode" Value="NoResize" />
  82. <Setter Property="Padding" Value="0" />
  83. <Setter Property="BorderThickness" Value="1" />
  84. <Setter Property="BorderBrush">
  85. <Setter.Value>
  86. <SolidColorBrush Opacity="0.3" Color="Gray" />
  87. </Setter.Value>
  88. </Setter>
  89. <Setter Property="Background" Value="Transparent" />
  90. </Style>
  91. </ResourceDictionary>