PopupWindow.xaml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <ResourceDictionary
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:ex="clr-namespace:HandyControl.Tools.Extension"
  5. xmlns:hc="clr-namespace:HandyControl.Controls"
  6. xmlns:interactivity="clr-namespace:HandyControl.Interactivity"
  7. xmlns:langs="clr-namespace:HandyControl.Properties.Langs">
  8. <Style TargetType="hc:PopupWindow">
  9. <Setter Property="WindowStyle" Value="None" />
  10. <Setter Property="MinHeight" Value="220" />
  11. <Setter Property="UseLayoutRounding" Value="True" />
  12. <Setter Property="BorderThickness" Value="20" />
  13. <Setter Property="ShowInTaskbar" Value="False" />
  14. <Setter Property="MinWidth" Value="300" />
  15. <Setter Property="ResizeMode" Value="NoResize" />
  16. <Setter Property="Background" Value="{DynamicResource RegionBrush}" />
  17. <Setter Property="SizeToContent" Value="WidthAndHeight" />
  18. <Setter Property="Effect">
  19. <Setter.Value>
  20. <DropShadowEffect
  21. BlurRadius="15"
  22. Opacity=".6"
  23. ShadowDepth="0" />
  24. </Setter.Value>
  25. </Setter>
  26. <Setter Property="Template">
  27. <Setter.Value>
  28. <ControlTemplate TargetType="hc:PopupWindow">
  29. <Border Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}">
  30. <Grid>
  31. <Grid.RowDefinitions>
  32. <RowDefinition Height="Auto" />
  33. <RowDefinition />
  34. <RowDefinition Height="Auto" />
  35. </Grid.RowDefinitions>
  36. <Grid
  37. Name="TitleGrid"
  38. Height="30"
  39. Background="{DynamicResource TitleBrush}">
  40. <Grid.ColumnDefinitions>
  41. <ColumnDefinition />
  42. <ColumnDefinition Width="Auto" />
  43. </Grid.ColumnDefinitions>
  44. <TextBlock
  45. Name="PART_TitleBlock"
  46. Padding="{StaticResource DefaultControlPadding}"
  47. VerticalAlignment="Center"
  48. Background="Transparent"
  49. Foreground="White"
  50. Text="{TemplateBinding Title}"
  51. TextTrimming="WordEllipsis"
  52. TextWrapping="Wrap" />
  53. <Button
  54. Name="CloseButton"
  55. Grid.Column="1"
  56. Width="44"
  57. Height="28"
  58. Margin="0,0,1,0"
  59. Padding="9"
  60. hc:BackgroundSwitchElement.MouseDownBackground="Red"
  61. hc:BackgroundSwitchElement.MouseHoverBackground="Red"
  62. Background="Transparent"
  63. Command="interactivity:ControlCommands.Close"
  64. Foreground="White"
  65. IsCancel="True"
  66. Style="{StaticResource ButtonCustom}">
  67. <Path Fill="{Binding ElementName=CloseButton, Path=Foreground}" Style="{StaticResource ClosePathStyle}" />
  68. </Button>
  69. </Grid>
  70. <Border
  71. Name="PART_MainBorder"
  72. Grid.Row="1"
  73. BorderBrush="{DynamicResource TitleBrush}">
  74. <StackPanel>
  75. <TextBlock
  76. Name="MyTextBlock"
  77. MinHeight="110"
  78. MaxWidth="300"
  79. Padding="32"
  80. Background="{TemplateBinding Background}"
  81. Foreground="{DynamicResource PrimaryTextBrush}"
  82. Text="{TemplateBinding ContentStr}"
  83. TextAlignment="Center"
  84. TextTrimming="CharacterEllipsis"
  85. TextWrapping="Wrap" />
  86. <StackPanel
  87. Margin="0,0,0,32"
  88. HorizontalAlignment="Center"
  89. Background="{DynamicResource RegionBrush}"
  90. Orientation="Horizontal">
  91. <Button
  92. MinWidth="80"
  93. Margin="0,0,16,0"
  94. Command="interactivity:ControlCommands.Cancel"
  95. Content="{ex:Lang Key={x:Static langs:LangKeys.Cancel}}"
  96. IsCancel="True"
  97. Visibility="{TemplateBinding ShowCancel,
  98. Converter={StaticResource Boolean2VisibilityConverter}}" />
  99. <Button
  100. MinWidth="80"
  101. Command="interactivity:ControlCommands.Confirm"
  102. Content="{ex:Lang Key={x:Static langs:LangKeys.Confirm}}"
  103. IsDefault="True"
  104. Style="{StaticResource ButtonPrimary}" />
  105. </StackPanel>
  106. </StackPanel>
  107. </Border>
  108. </Grid>
  109. </Border>
  110. <ControlTemplate.Triggers>
  111. <Trigger Property="ShowBorder" Value="True">
  112. <Setter TargetName="PART_MainBorder" Property="BorderThickness" Value="1,0,1,1" />
  113. </Trigger>
  114. <Trigger Property="ShowTitle" Value="False">
  115. <Setter TargetName="TitleGrid" Property="Visibility" Value="Collapsed" />
  116. <Setter Property="Background" Value="Transparent" />
  117. </Trigger>
  118. </ControlTemplate.Triggers>
  119. </ControlTemplate>
  120. </Setter.Value>
  121. </Setter>
  122. </Style>
  123. </ResourceDictionary>