-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFormField.axaml
139 lines (136 loc) · 6.52 KB
/
FormField.axaml
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
127
128
129
130
131
132
133
134
135
136
137
138
139
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ctrl="clr-namespace:AvaloniaUILib.Controls">
<Design.PreviewWith>
<Grid RowDefinitions="Auto,Auto,Auto,Auto">
<!-- Grid LayOut -->
<Border Padding="10" BorderBrush="Red"
BorderThickness="2">
<Grid ColumnDefinitions="Auto,Auto"
RowDefinitions="Auto,Auto"
ShowGridLines="True">
<ctrl:FormField HorizontalAlignment="Right" Header="Field One">
<TextBox Width="100" />
</ctrl:FormField>
<ctrl:FormField Column="1" Header="Field Two">
<TextBox Width="100" />
</ctrl:FormField>
<ctrl:FormField Header="Field ThreeABCDDEF" Row="1"
RowSpan="2">
<TextBox Width="100" />
</ctrl:FormField>
</Grid>
</Border>
<!-- Grid LayOut -->
<!-- StackPanel Layout -->
<Border Grid.Row="1" Padding="10"
BorderBrush="Red"
BorderThickness="2">
<StackPanel>
<ctrl:FormField Header="Field One">
<TextBox />
</ctrl:FormField>
<ctrl:FormField Header="Field Two">
<TextBox />
</ctrl:FormField>
<ctrl:FormField Header="Field ThreeABCDDEF">
<TextBox />
</ctrl:FormField>
</StackPanel>
</Border>
<!-- StackPanel Layout -->
<!-- ItemsControl Layout -->
<Border Grid.Row="2" Padding="10"
BorderBrush="Red"
BorderThickness="2">
<ItemsControl Grid.IsSharedSizeScope="True">
<ItemsControl.ItemTemplate>
<DataTemplate>
<ctrl:FormField Header="{Binding}">
<TextBox Text="{Binding}" />
</ctrl:FormField>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.Items>
<x:Int32>1</x:Int32>
<x:Int32>23</x:Int32>
<x:Int32>456</x:Int32>
<x:Int32>7890</x:Int32>
</ItemsControl.Items>
</ItemsControl>
</Border>
<!-- ItemsControl Layout -->
<!-- HeaderPanel Layout -->
<Border Grid.Row="3" Padding="10"
BorderBrush="Red"
BorderThickness="2">
<ItemsControl Grid.IsSharedSizeScope="True">
<ItemsControl.ItemTemplate>
<DataTemplate>
<ctrl:FormField ContainerPosition="Bottom" Header="{Binding}">
<TextBox Text="{Binding}" />
</ctrl:FormField>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.Items>
<x:Int32>1</x:Int32>
<x:Int32>23</x:Int32>
<x:Int32>456</x:Int32>
<x:Int32>7890</x:Int32>
</ItemsControl.Items>
</ItemsControl>
</Border>
<!-- HeaderPanel Layout -->
</Grid>
</Design.PreviewWith>
<!-- Add Styles Here -->
<Style Selector="ctrl|FormField">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ctrl:FormField">
<Border Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Grid x:Name="Grid_Content"
ClipToBounds="True"
ColumnDefinitions="Auto,0,*"
RowDefinitions="Auto,0,*">
<ContentPresenter x:Name="PART_Field"
Margin="{TemplateBinding HeaderMargin}"
HorizontalAlignment="{TemplateBinding HorizontalHeaderAlignment}"
VerticalAlignment="{TemplateBinding VerticalHeaderAlignment}"
Content="{TemplateBinding Header}" />
<ContentPresenter x:Name="PART_FieldEditor"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}" />
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style Selector="ctrl|FormField:content-right /template/ ContentPresenter#PART_FieldEditor">
<Setter Property="Grid.Row" Value="0" />
<Setter Property="Grid.RowSpan" Value="3" />
<Setter Property="Grid.Column" Value="2" />
<Setter Property="Grid.ColumnSpan" Value="1" />
</Style>
<Style Selector="ctrl|FormField:content-right /template/ ContentPresenter#PART_Field">
<Setter Property="Grid.RowSpan" Value="3" />
<Setter Property="Grid.ColumnSpan" Value="1" />
</Style>
<Style Selector="ctrl|FormField:content-bottom /template/ ContentPresenter#PART_FieldEditor">
<Setter Property="Grid.Column" Value="0" />
<Setter Property="Grid.ColumnSpan" Value="3" />
<Setter Property="Grid.Row" Value="2" />
<Setter Property="Grid.RowSpan" Value="1" />
</Style>
<Style Selector="ctrl|FormField:content-bottom /template/ ContentPresenter#PART_Field">
<Setter Property="Grid.RowSpan" Value="1" />
<Setter Property="Grid.ColumnSpan" Value="3" />
</Style>
</Styles>