WindowsStyle.xaml 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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="0"
  11. GlassFrameThickness="0"
  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. Effect="{StaticResource shadow.black-2-2}">
  59. <Grid>
  60. <!-- esc关闭窗体按钮 -->
  61. <Button
  62. HorizontalAlignment="Center"
  63. VerticalAlignment="Center"
  64. Background="Transparent"
  65. IsCancel="True" />
  66. <AdornerDecorator>
  67. <ContentPresenter x:Name="win_content" />
  68. </AdornerDecorator>
  69. </Grid>
  70. </Border>
  71. <ControlTemplate.Triggers>
  72. <Trigger Property="WindowState" Value="Maximized">
  73. <!-- 调整边框 -->
  74. <Setter TargetName="win_content" Property="Margin" Value="5,5,5,5" />
  75. </Trigger>
  76. </ControlTemplate.Triggers>
  77. </ControlTemplate>
  78. </Setter.Value>
  79. </Setter>
  80. </Style>
  81. <Style x:Key="WindowNoCorderStyle" TargetType="{x:Type Window}">
  82. <Setter Property="WindowChrome.WindowChrome">
  83. <Setter.Value>
  84. <WindowChrome
  85. CaptionHeight="48"
  86. CornerRadius="0"
  87. GlassFrameThickness="-1"
  88. ResizeBorderThickness="5"
  89. UseAeroCaptionButtons="False" />
  90. </Setter.Value>
  91. </Setter>
  92. <Setter Property="Template">
  93. <Setter.Value>
  94. <ControlTemplate TargetType="{x:Type Window}">
  95. <Border
  96. Margin="20"
  97. Background="{TemplateBinding Background}"
  98. BorderBrush="{TemplateBinding BorderBrush}"
  99. BorderThickness="{TemplateBinding BorderThickness}"
  100. CornerRadius="0">
  101. <Grid>
  102. <!-- esc关闭窗体按钮 -->
  103. <Button
  104. HorizontalAlignment="Center"
  105. VerticalAlignment="Center"
  106. Background="Transparent"
  107. IsCancel="True" Width="0" Height="0"/>
  108. <AdornerDecorator>
  109. <ContentPresenter x:Name="win_content" />
  110. </AdornerDecorator>
  111. </Grid>
  112. </Border>
  113. <ControlTemplate.Triggers>
  114. <Trigger Property="WindowState" Value="Maximized">
  115. <!-- 调整边框 -->
  116. <Setter TargetName="win_content" Property="Margin" Value="5,5,5,5" />
  117. </Trigger>
  118. </ControlTemplate.Triggers>
  119. </ControlTemplate>
  120. </Setter.Value>
  121. </Setter>
  122. </Style>
  123. <!-- 弹窗的窗体样式 -->
  124. <Style
  125. x:Key="DialogWindowStyle"
  126. BasedOn="{StaticResource WindowNoCorderStyle}"
  127. TargetType="{x:Type Window}">
  128. <Setter Property="prism:Dialog.WindowStartupLocation" Value="CenterOwner" />
  129. <Setter Property="SizeToContent" Value="WidthAndHeight" />
  130. <Setter Property="ShowInTaskbar" Value="False" />
  131. <Setter Property="ResizeMode" Value="NoResize" />
  132. <Setter Property="Padding" Value="0" />
  133. <Setter Property="BorderThickness" Value="0" />
  134. <Setter Property="BorderBrush">
  135. <Setter.Value>
  136. <SolidColorBrush Opacity="0.3" Color="Gray" />
  137. </Setter.Value>
  138. </Setter>
  139. <Setter Property="Background" Value="Transparent" />
  140. </Style>
  141. <Style
  142. x:Key="Caption16DialogWindowStyle"
  143. BasedOn="{StaticResource DialogWindowStyle}"
  144. TargetType="{x:Type Window}">
  145. <Setter Property="WindowChrome.WindowChrome">
  146. <Setter.Value>
  147. <WindowChrome
  148. CaptionHeight="16"
  149. CornerRadius="15"
  150. GlassFrameThickness="-1"
  151. ResizeBorderThickness="5"
  152. UseAeroCaptionButtons="False" />
  153. </Setter.Value>
  154. </Setter>
  155. </Style>
  156. <Style
  157. x:Key="InfoDialogWindowStyle"
  158. BasedOn="{StaticResource WindowWithCorderStyle}"
  159. TargetType="{x:Type Window}">
  160. <Setter Property="WindowStyle" Value="ThreeDBorderWindow" />
  161. <Setter Property="prism:Dialog.WindowStartupLocation" Value="CenterOwner" />
  162. <Setter Property="SizeToContent" Value="WidthAndHeight" />
  163. <Setter Property="ShowInTaskbar" Value="True" />
  164. <Setter Property="ResizeMode" Value="NoResize" />
  165. <Setter Property="Padding" Value="0" />
  166. <Setter Property="BorderThickness" Value="1" />
  167. <Setter Property="BorderBrush">
  168. <Setter.Value>
  169. <SolidColorBrush Opacity="0.3" Color="Gray" />
  170. </Setter.Value>
  171. </Setter>
  172. <Setter Property="Background" Value="Transparent" />
  173. </Style>
  174. <Style
  175. x:Key="stlWindowEx"
  176. BasedOn="{StaticResource DialogWindowStyle}"
  177. TargetType="{x:Type Window}">
  178. <Setter Property="ResizeMode" Value="CanResize" />
  179. </Style>
  180. </ResourceDictionary>