WindowsStyle.xaml 3.9 KB

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