BaseStyle.xaml
4.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<!-- 用以设置各样式的FontSize属性 -->
<system:Double x:Key="sizeValue">16</system:Double>
<!--<Style
x:Key="BaseTextBoxStyle"
BasedOn="{StaticResource {x:Type TextBox}}"
TargetType="TextBox">
<Setter Property="MinWidth" Value="80" />
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="True">
<Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent}" />
</Trigger>
</Style.Triggers>
</Style>-->
<Style
x:Key="BaseTextBlockStyle"
BasedOn="{StaticResource {x:Type TextBlock}}"
TargetType="TextBlock">
<Setter Property="FontSize" Value="{StaticResource sizeValue}" />
</Style>
<Style
x:Key="BaseButtonStyle"
BasedOn="{StaticResource {x:Type Button}}"
TargetType="Button">
<Setter Property="FontSize" Value="{StaticResource sizeValue}" />
</Style>
<Style
x:Key="BaseRadioButtonStyle"
BasedOn="{StaticResource {x:Type RadioButton}}"
TargetType="RadioButton">
<Setter Property="FontSize" Value="{StaticResource sizeValue}" />
</Style>
<Style
x:Key="BaseCheckBoxStyle"
BasedOn="{StaticResource {x:Type CheckBox}}"
TargetType="CheckBox">
<Setter Property="FontSize" Value="{StaticResource sizeValue}" />
</Style>
<Style
x:Key="BaseDataGridRowStyle"
BasedOn="{StaticResource DataGridRowStyle}"
TargetType="DataGridRow" />
<!--<Style x:Key="BaseDataGridRowStyle" TargetType="DataGridRow" BasedOn="{StaticResource {x:Type DataGridRow}}"></Style>-->
<Style
x:Key="BaseDataGridCellStyle"
BasedOn="{StaticResource DataGridCellStyle}"
TargetType="DataGridCell" />
<!--<Style x:Key="BaseDataGridCellStyle" TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}"></Style>-->
<Style
x:Key="BaseDataGridStyle"
BasedOn="{StaticResource {x:Type DataGrid}}"
TargetType="DataGrid">
<Setter Property="AutoGenerateColumns" Value="False" />
<Setter Property="IsReadOnly" Value="True" />
</Style>
<!-- 简单校验错误模板 -->
<ControlTemplate x:Key="ErrorTemplate">
<Border BorderBrush="Red" BorderThickness="1">
<AdornedElementPlaceholder />
</Border>
</ControlTemplate>
<!-- 全局 -->
<Style BasedOn="{StaticResource {x:Type DataGrid}}" TargetType="DataGrid">
<Setter Property="AutoGenerateColumns" Value="False" />
<Setter Property="IsReadOnly" Value="True" />
<Setter Property="CanUserAddRows" Value="False" />
<Setter Property="CanUserDeleteRows" Value="False" />
</Style>
<Style BasedOn="{StaticResource DataGridColumnHeaderStyle}" TargetType="DataGridColumnHeader">
<!--<Setter Property="Padding" Value="12,0,12,0" />-->
<!-- 左,上,右,下 -->
<!--<Setter Property="MinHeight" Value="5" />-->
<!--<Setter Property="Height" Value="Auto" />-->
</Style>
<Style BasedOn="{StaticResource {x:Type Menu}}" TargetType="Menu">
<Setter Property="FontSize" Value="{StaticResource sizeValue}" />
</Style>
<Style BasedOn="{StaticResource {x:Type MenuItem}}" TargetType="MenuItem">
<Setter Property="FontSize" Value="{StaticResource sizeValue}" />
</Style>
<Style BasedOn="{StaticResource {x:Type TextBlock}}" TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<Style BasedOn="{StaticResource {x:Type ComboBox}}" TargetType="ComboBox">
<Setter Property="Validation.ErrorTemplate" Value="{StaticResource ErrorTemplate}" />
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="True">
<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}" />
</Trigger>
</Style.Triggers>
</Style>
<Style BasedOn="{StaticResource {x:Type TextBox}}" TargetType="TextBox">
<Setter Property="Validation.ErrorTemplate" Value="{StaticResource ErrorTemplate}" />
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="True">
<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}" />
</Trigger>
</Style.Triggers>
</Style>
<Style BasedOn="{StaticResource {x:Type Button}}" TargetType="Button">
<Setter Property="FontSize" Value="{StaticResource sizeValue}" />
</Style>
</ResourceDictionary>