-
Notifications
You must be signed in to change notification settings - Fork 0
/
FormField.xaml
58 lines (56 loc) · 3.9 KB
/
FormField.xaml
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
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ctrl="clr-namespace:Flithor_ReusableCodes.Controls">
<Style TargetType="{x:Type ctrl:FormField}">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ctrl:FormField}">
<Border Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Grid x:Name="grid">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="PART_FieldWidth" Width="Auto" />
<ColumnDefinition x:Name="HorizontalGap" Width="{TemplateBinding Gap}" />
<ColumnDefinition x:Name="HorizontalContainer" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition x:Name="PART_FieldHigth" Height="Auto" />
<RowDefinition x:Name="VerticalGap" Height="0" />
<RowDefinition x:Name="VerticalContainer" />
</Grid.RowDefinitions>
<ContentPresenter x:Name="PART_Field"
Grid.RowSpan="3"
HorizontalAlignment="{TemplateBinding HorizontalHeaderAlignment}"
VerticalAlignment="{TemplateBinding VerticalHeaderAlignment}"
ContentSource="Header" />
<ContentPresenter x:Name="PART_FieldEditor"
Grid.Row="0" Grid.RowSpan="3"
Grid.Column="2"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
ContentSource="Content" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="ContainerPosition" Value="Bottom">
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter TargetName="PART_FieldEditor" Property="Grid.Column" Value="0" />
<Setter TargetName="PART_FieldEditor" Property="Grid.ColumnSpan" Value="3" />
<Setter TargetName="PART_FieldEditor" Property="Grid.Row" Value="2" />
<Setter TargetName="PART_FieldEditor" Property="Grid.RowSpan" Value="1" />
<Setter TargetName="PART_Field" Property="Grid.RowSpan" Value="1" />
<Setter TargetName="PART_Field" Property="Grid.ColumnSpan" Value="3" />
<Setter TargetName="HorizontalGap" Property="Width" Value="0" />
<Setter TargetName="VerticalGap" Property="Height" Value="{Binding Gap, RelativeSource={RelativeSource Mode=TemplatedParent}}" />
<Setter TargetName="VerticalContainer" Property="Height" Value="*" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>