WindowsStyle.xaml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. 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="InfoDialogWindowStyle"
  102. BasedOn="{StaticResource WindowWithCorderStyle}"
  103. TargetType="{x:Type Window}">
  104. <Setter Property="WindowStyle" Value="ThreeDBorderWindow" />
  105. <Setter Property="prism:Dialog.WindowStartupLocation" Value="CenterOwner" />
  106. <Setter Property="SizeToContent" Value="WidthAndHeight" />
  107. <Setter Property="ShowInTaskbar" Value="True" />
  108. <Setter Property="ResizeMode" Value="NoResize" />
  109. <Setter Property="Padding" Value="0" />
  110. <Setter Property="BorderThickness" Value="1" />
  111. <Setter Property="BorderBrush">
  112. <Setter.Value>
  113. <SolidColorBrush Opacity="0.3" Color="Gray" />
  114. </Setter.Value>
  115. </Setter>
  116. <Setter Property="Background" Value="Transparent" />
  117. </Style>
  118. </ResourceDictionary>