feat: improve demo, add dynamic resource.
This commit is contained in:
@@ -12,47 +12,47 @@
|
|||||||
x:CompileBindings="True"
|
x:CompileBindings="True"
|
||||||
x:DataType="vm:FormDemoViewModel"
|
x:DataType="vm:FormDemoViewModel"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<StackPanel>
|
<ScrollViewer>
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<u:EnumSelector
|
<Grid RowDefinitions="Auto, Auto" ColumnDefinitions="Auto, Auto">
|
||||||
Name="position"
|
<TextBlock Grid.Row="0" Grid.Column="0" Text="Label Position" VerticalAlignment="Center"></TextBlock>
|
||||||
EnumType="common:Position"
|
<TextBlock Grid.Row="1" Grid.Column="0" Text="Label Alignment" VerticalAlignment="Center"></TextBlock>
|
||||||
Value="{x:Static common:Position.Top}" />
|
<u:EnumSelector Grid.Row="0" Grid.Column="1"
|
||||||
<u:EnumSelector
|
Name="position"
|
||||||
Name="alignment"
|
EnumType="common:Position"
|
||||||
EnumType="HorizontalAlignment"
|
Value="{x:Static common:Position.Top}" />
|
||||||
Value="{x:Static HorizontalAlignment.Left}" />
|
<u:EnumSelector Grid.Row="1" Grid.Column="1"
|
||||||
|
Name="alignment"
|
||||||
|
EnumType="HorizontalAlignment"
|
||||||
|
Value="{x:Static HorizontalAlignment.Left}" />
|
||||||
|
</Grid>
|
||||||
|
<u:Form
|
||||||
|
DataContext="{Binding Model}"
|
||||||
|
LabelAlignment="{Binding #alignment.Value}"
|
||||||
|
LabelPosition="{Binding #position.Value}"
|
||||||
|
LabelWidth="*">
|
||||||
|
<u:FormGroup Header="Information">
|
||||||
|
<TextBox
|
||||||
|
Width="300"
|
||||||
|
u:FormItem.IsRequired="True"
|
||||||
|
u:FormItem.Label="Name"
|
||||||
|
Text="{Binding Name}" />
|
||||||
|
<TextBox
|
||||||
|
Width="300"
|
||||||
|
u:FormItem.Label="Email"
|
||||||
|
Text="{Binding Email}" />
|
||||||
|
</u:FormGroup>
|
||||||
|
<u:FormItem Label="Please select a Date">
|
||||||
|
<CalendarDatePicker SelectedDate="{Binding Date}" />
|
||||||
|
</u:FormItem>
|
||||||
|
<u:FormItem Label="Click to Submit">
|
||||||
|
<Button Content="Button With Label" />
|
||||||
|
</u:FormItem>
|
||||||
|
<CheckBox Content="I Agree User Agreement" u:FormItem.NoLabel="True"></CheckBox>
|
||||||
|
<u:FormItem NoLabel="True">
|
||||||
|
<Button HorizontalAlignment="Left" Content="No Label" />
|
||||||
|
</u:FormItem>
|
||||||
|
</u:Form>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<u:Form
|
</ScrollViewer>
|
||||||
DataContext="{Binding Model}"
|
|
||||||
LabelAlignment="{Binding #alignment.Value}"
|
|
||||||
LabelPosition="{Binding #position.Value}"
|
|
||||||
LabelWidth="*">
|
|
||||||
<u:FormGroup Header="Information">
|
|
||||||
<TextBox
|
|
||||||
Width="300"
|
|
||||||
u:FormItem.IsRequired="True"
|
|
||||||
u:FormItem.Label="Name"
|
|
||||||
Text="{Binding Name}" />
|
|
||||||
<TextBox
|
|
||||||
Width="300"
|
|
||||||
u:FormItem.Label="Email"
|
|
||||||
Text="{Binding Email}" />
|
|
||||||
</u:FormGroup>
|
|
||||||
<u:FormItem Label="Please select a Date">
|
|
||||||
<Calendar SelectedDate="{Binding Date}" />
|
|
||||||
</u:FormItem>
|
|
||||||
<u:FormItem Label="Click to Submit">
|
|
||||||
<Button Content="With Label" />
|
|
||||||
</u:FormItem>
|
|
||||||
<u:FormItem NoLabel="True">
|
|
||||||
<Button HorizontalAlignment="Left" Content="No Label" />
|
|
||||||
</u:FormItem>
|
|
||||||
</u:Form>
|
|
||||||
<StackPanel>
|
|
||||||
<TextBlock Text="{Binding Model.Name}" />
|
|
||||||
<TextBlock Text="{Binding Model.Email}" />
|
|
||||||
<TextBlock Text="{Binding Model.Date}" />
|
|
||||||
</StackPanel>
|
|
||||||
</StackPanel>
|
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -22,12 +22,12 @@
|
|||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<ControlTemplate TargetType="u:FormGroup">
|
<ControlTemplate TargetType="u:FormGroup">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<ContentPresenter Content="{TemplateBinding Header}" FontWeight="Bold" />
|
<ContentPresenter Content="{TemplateBinding Header}" FontWeight="Bold" FontSize="18" />
|
||||||
<Rectangle
|
<Rectangle
|
||||||
Height="1"
|
Height="1"
|
||||||
Margin="0,8"
|
Margin="0,8"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
Fill="LightGray" />
|
Fill="{DynamicResource FormGroupBorderBrush}" />
|
||||||
<ItemsPresenter ItemsPanel="{TemplateBinding ItemsPanel}" />
|
<ItemsPresenter ItemsPanel="{TemplateBinding ItemsPanel}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
|
|||||||
5
src/Ursa.Themes.Semi/Themes/Dark/Form.axaml
Normal file
5
src/Ursa.Themes.Semi/Themes/Dark/Form.axaml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
<!-- Add Resources Here -->
|
||||||
|
<SolidColorBrush x:Key="FormGroupBorderBrush" Color="White" Opacity="0.08"></SolidColorBrush>
|
||||||
|
</ResourceDictionary>
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
<MergeResourceInclude Source="Dialog.axaml" />
|
<MergeResourceInclude Source="Dialog.axaml" />
|
||||||
<MergeResourceInclude Source="Divider.axaml" />
|
<MergeResourceInclude Source="Divider.axaml" />
|
||||||
<MergeResourceInclude Source="DualBadge.axaml" />
|
<MergeResourceInclude Source="DualBadge.axaml" />
|
||||||
|
<MergeResourceInclude Source="Form.axaml" />
|
||||||
<MergeResourceInclude Source="IPv4Box.axaml" />
|
<MergeResourceInclude Source="IPv4Box.axaml" />
|
||||||
<MergeResourceInclude Source="KeyGestureInput.axaml" />
|
<MergeResourceInclude Source="KeyGestureInput.axaml" />
|
||||||
<MergeResourceInclude Source="Loading.axaml" />
|
<MergeResourceInclude Source="Loading.axaml" />
|
||||||
|
|||||||
5
src/Ursa.Themes.Semi/Themes/Light/Form.axaml
Normal file
5
src/Ursa.Themes.Semi/Themes/Light/Form.axaml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
<!-- Add Resources Here -->
|
||||||
|
<SolidColorBrush x:Key="FormGroupBorderBrush" Color="#FF1C1F23" Opacity="0.08"></SolidColorBrush>
|
||||||
|
</ResourceDictionary>
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
<MergeResourceInclude Source="Dialog.axaml" />
|
<MergeResourceInclude Source="Dialog.axaml" />
|
||||||
<MergeResourceInclude Source="Divider.axaml" />
|
<MergeResourceInclude Source="Divider.axaml" />
|
||||||
<MergeResourceInclude Source="DualBadge.axaml" />
|
<MergeResourceInclude Source="DualBadge.axaml" />
|
||||||
|
<MergeResourceInclude Source="Form.axaml" />
|
||||||
<MergeResourceInclude Source="IPv4Box.axaml" />
|
<MergeResourceInclude Source="IPv4Box.axaml" />
|
||||||
<MergeResourceInclude Source="KeyGestureInput.axaml" />
|
<MergeResourceInclude Source="KeyGestureInput.axaml" />
|
||||||
<MergeResourceInclude Source="Loading.axaml" />
|
<MergeResourceInclude Source="Loading.axaml" />
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ public class Form: ItemsControl
|
|||||||
Content = control,
|
Content = control,
|
||||||
[!FormItem.LabelProperty] = control[!FormItem.LabelProperty],
|
[!FormItem.LabelProperty] = control[!FormItem.LabelProperty],
|
||||||
[!FormItem.IsRequiredProperty] = control[!FormItem.IsRequiredProperty],
|
[!FormItem.IsRequiredProperty] = control[!FormItem.IsRequiredProperty],
|
||||||
|
[!FormItem.NoLabelProperty] = control[!FormItem.NoLabelProperty],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user