WindowsStyle.xaml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. <!-- 弹窗的窗体样式 -->
  82. <Style
  83. x:Key="DialogWindowStyle"
  84. BasedOn="{StaticResource WindowWithCorderStyle}"
  85. TargetType="{x:Type Window}">
  86. <Setter Property="WindowStyle" Value="None" />
  87. <Setter Property="prism:Dialog.WindowStartupLocation" Value="CenterOwner" />
  88. <Setter Property="SizeToContent" Value="WidthAndHeight" />
  89. <Setter Property="ShowInTaskbar" Value="False" />
  90. <Setter Property="ResizeMode" Value="NoResize" />
  91. <Setter Property="Padding" Value="0" />
  92. <Setter Property="BorderThickness" Value="1" />
  93. <Setter Property="BorderBrush">
  94. <Setter.Value>
  95. <SolidColorBrush Opacity="0.3" Color="Gray" />
  96. </Setter.Value>
  97. </Setter>
  98. <Setter Property="Background" Value="Transparent" />
  99. </Style>
  100. <Style
  101. x:Key="Caption16DialogWindowStyle"
  102. BasedOn="{StaticResource DialogWindowStyle}"
  103. TargetType="{x:Type Window}">
  104. <Setter Property="WindowChrome.WindowChrome">
  105. <Setter.Value>
  106. <WindowChrome
  107. CaptionHeight="16"
  108. CornerRadius="15"
  109. GlassFrameThickness="-1"
  110. ResizeBorderThickness="5"
  111. UseAeroCaptionButtons="False" />
  112. </Setter.Value>
  113. </Setter>
  114. </Style>
  115. <Style
  116. x:Key="InfoDialogWindowStyle"
  117. BasedOn="{StaticResource WindowWithCorderStyle}"
  118. TargetType="{x:Type Window}">
  119. <Setter Property="WindowStyle" Value="ThreeDBorderWindow" />
  120. <Setter Property="prism:Dialog.WindowStartupLocation" Value="CenterOwner" />
  121. <Setter Property="SizeToContent" Value="WidthAndHeight" />
  122. <Setter Property="ShowInTaskbar" Value="True" />
  123. <Setter Property="ResizeMode" Value="NoResize" />
  124. <Setter Property="Padding" Value="0" />
  125. <Setter Property="BorderThickness" Value="1" />
  126. <Setter Property="BorderBrush">
  127. <Setter.Value>
  128. <SolidColorBrush Opacity="0.3" Color="Gray" />
  129. </Setter.Value>
  130. </Setter>
  131. <Setter Property="Background" Value="Transparent" />
  132. </Style>
  133. <Style
  134. x:Key="stlWindowEx"
  135. BasedOn="{StaticResource DialogWindowStyle}"
  136. TargetType="{x:Type Window}">
  137. <Setter Property="ResizeMode" Value="CanResize" />
  138. </Style>
  139. </ResourceDictionary>