feat: options.

This commit is contained in:
Zhang Dian
2024-06-14 18:47:16 +08:00
parent 8390e6e674
commit 1b7ee4a04d
2 changed files with 229 additions and 166 deletions

View File

@@ -5,51 +5,89 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:u="https://irihi.tech/ursa" xmlns:u="https://irihi.tech/ursa"
xmlns:viewModels="clr-namespace:Ursa.Demo.ViewModels" xmlns:viewModels="clr-namespace:Ursa.Demo.ViewModels"
d:DesignHeight="450" d:DesignHeight="800"
d:DesignWidth="800" d:DesignWidth="800"
x:CompileBindings="True" x:CompileBindings="True"
x:DataType="viewModels:ElasticWrapPanelDemoViewModel" x:DataType="viewModels:ElasticWrapPanelDemoViewModel"
mc:Ignorable="d"> mc:Ignorable="d">
<UserControl.Styles>
<Style Selector="u|FormItem">
<Setter Property="Width" Value="320" />
</Style>
</UserControl.Styles>
<DockPanel> <DockPanel>
<StackPanel x:Name="ControlBar" DockPanel.Dock="Top"> <u:Form DockPanel.Dock="Left"
<StackPanel Orientation="Horizontal"> LabelAlignment="Left"
<TextBlock Text="Orientation" /> LabelPosition="Left"
<ComboBox ItemsSource="{Binding Orientations}" SelectedItem="{Binding SelectedOrientation}" /> LabelWidth="*">
<TextBlock Text="HorizontalScrollBar" /> <u:FormGroup>
<ComboBox ItemsSource="{Binding HScrollBarVisibilities}" SelectedItem="{Binding HorizontalVisibility}" /> <u:FormItem Label="Orientation">
<TextBlock Text="VerticalScrollBar" /> <ComboBox ItemsSource="{Binding Orientations}" SelectedItem="{Binding SelectedOrientation}" />
<ComboBox ItemsSource="{Binding VScrollBarVisibilities}" SelectedItem="{Binding VerticalVisibility}" /> </u:FormItem>
</StackPanel> <u:FormItem Label="HorizontalScrollBar">
<StackPanel Orientation="Horizontal"> <ComboBox ItemsSource="{Binding HScrollBarVisibilities}"
<CheckBox Content="IsFillHorizontal" IsChecked="{Binding IsFillHorizontal}" /> SelectedItem="{Binding HorizontalVisibility}" />
<TextBlock Text="ItemWidth" /> </u:FormItem>
<NumericUpDown Increment="1" <u:FormItem Label="VerticalScrollBar">
Maximum="1000" <ComboBox ItemsSource="{Binding VScrollBarVisibilities}"
Minimum="0" SelectedIndex="{Binding VerticalVisibility}" />
Value="{Binding ItemWidth}" /> </u:FormItem>
</StackPanel> <u:FormItem>
<StackPanel Orientation="Horizontal"> <u:FormItem.Label>
<CheckBox Content="IsFillVertical" IsChecked="{Binding IsFillVertical}" /> <CheckBox Content="IsFillHorizontal" IsChecked="{Binding IsFillHorizontal}" />
<TextBlock Text="ItemHeight" /> </u:FormItem.Label>
<NumericUpDown Increment="1" <u:NumericDoubleUpDown
Maximum="1000" InnerLeftContent="ItemWidth"
Minimum="0" Step="1"
Value="{Binding ItemHeight}" /> AllowDrag="True"
</StackPanel> Maximum="1000"
<StackPanel.Styles> Minimum="0"
<Style Selector="StackPanel#ControlBar &gt; StackPanel &gt; TextBlock"> Value="{Binding ItemWidth}" />
<Setter Property="VerticalAlignment" Value="Center" /> </u:FormItem>
<Setter Property="Margin" Value="10 0" /> <u:FormItem>
</Style> <u:FormItem.Label>
<Style Selector="StackPanel#ControlBar &gt; StackPanel &gt; TextBox, NumericUpDown"> <CheckBox Content="IsFillVertical" IsChecked="{Binding IsFillVertical}" />
<Setter Property="Width" Value="100" /> </u:FormItem.Label>
</Style> <u:NumericDoubleUpDown
<Style Selector="StackPanel#ControlBar &gt; StackPanel &gt; ComboBox"> InnerLeftContent="ItemHeight"
<Setter Property="Width" Value="130" /> AllowDrag="True"
</Style> Step="1"
</StackPanel.Styles> Maximum="1000"
</StackPanel> Minimum="0"
Value="{Binding ItemHeight}" />
</u:FormItem>
</u:FormGroup>
<u:FormGroup Header="FixToRB Extension" IsEnabled="{Binding #FixToRBTabItem.IsSelected}">
<u:FormItem>
<u:FormItem.Label>
<CheckBox Content="AutoWidth" IsChecked="{Binding AutoWidth}" />
</u:FormItem.Label>
<u:NumericDoubleUpDown
AllowDrag="True"
Maximum="1000"
Minimum="0"
IsEnabled="{Binding !AutoWidth}"
Value="{Binding ItemSelfWidth}" />
</u:FormItem>
<u:FormItem>
<u:FormItem.Label>
<CheckBox Content="AutoHeight" IsChecked="{Binding AutoHeight}" />
</u:FormItem.Label>
<u:NumericDoubleUpDown
AllowDrag="True"
Maximum="1000"
Minimum="0"
IsEnabled="{Binding !AutoHeight}"
Value="{Binding ItemSelfHeight}" />
</u:FormItem>
<u:FormItem Label="Horizontal Alignment">
<ComboBox ItemsSource="{Binding CmbHAligns}" SelectedItem="{Binding CmbHAlign}" />
</u:FormItem>
<u:FormItem Label="Vertical Alignment">
<ComboBox ItemsSource="{Binding CmbVAligns}" SelectedItem="{Binding CmbVAlign}" />
</u:FormItem>
</u:FormGroup>
</u:Form>
<TabControl> <TabControl>
<TabItem Header="Flat"> <TabItem Header="Flat">
<TabControl> <TabControl>
@@ -102,19 +140,15 @@
<Border Background="{DynamicResource SemiOrange5Color}" /> <Border Background="{DynamicResource SemiOrange5Color}" />
<Border Background="{DynamicResource SemiGrey5Color}" /> <Border Background="{DynamicResource SemiGrey5Color}" />
</u:ElasticWrapPanel> </u:ElasticWrapPanel>
<Border Grid.Row="1" <Border Grid.Row="1" Margin="0,4" Theme="{StaticResource CardBorder}">
Margin="0,4"
BorderBrush="{DynamicResource SemiGrey9Color}"
BorderThickness="1">
<TextBlock Text="This is blank" /> <TextBlock Text="This is blank" />
</Border> </Border>
</Grid> </Grid>
</TabItem> </TabItem>
<TabItem Header="ScrollViewer"> <TabItem Header="ScrollViewer">
<Border Margin="0,4" <Border Margin="0,4">
BorderBrush="{DynamicResource SemiGrey9Color}" <ScrollViewer HorizontalScrollBarVisibility="{Binding HorizontalVisibility}"
BorderThickness="1"> VerticalScrollBarVisibility="{Binding VerticalVisibility}">
<ScrollViewer HorizontalScrollBarVisibility="{Binding HorizontalVisibility}" VerticalScrollBarVisibility="{Binding VerticalVisibility}">
<u:ElasticWrapPanel IsFillHorizontal="{Binding IsFillHorizontal}" <u:ElasticWrapPanel IsFillHorizontal="{Binding IsFillHorizontal}"
IsFillVertical="{Binding IsFillVertical}" IsFillVertical="{Binding IsFillVertical}"
ItemHeight="{Binding ItemHeight}" ItemHeight="{Binding ItemHeight}"
@@ -143,39 +177,13 @@
</TabControl> </TabControl>
</TabItem> </TabItem>
<TabItem Header="FixToRB"> <TabItem Header="FixToRB" Name="FixToRBTabItem">
<DockPanel> <DockPanel>
<StackPanel x:Name="ControlBar2" DockPanel.Dock="Top">
<StackPanel Orientation="Horizontal">
<TextBlock Text="Control Width" />
<TextBox Text="{Binding ItemSelfWidth}" />
<TextBlock Text="Control Height" />
<TextBox Text="{Binding ItemSelfHeight}" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Horizontal Alignment" />
<ComboBox ItemsSource="{Binding CmbHAligns}" SelectedItem="{Binding CmbHAlign}" />
<TextBlock Text="Vertical Alignment" />
<ComboBox ItemsSource="{Binding CmbVAligns}" SelectedItem="{Binding CmbVAlign}" />
</StackPanel>
<StackPanel.Styles>
<Style Selector="StackPanel#ControlBar2 &gt; StackPanel &gt; TextBlock">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="10 0" />
</Style>
<Style Selector="StackPanel#ControlBar2 &gt; StackPanel &gt; TextBox, NumericUpDown">
<Setter Property="Width" Value="100" />
</Style>
<Style Selector="StackPanel#ControlBar2 &gt; StackPanel &gt; ComboBox">
<Setter Property="Width" Value="130" />
</Style>
</StackPanel.Styles>
</StackPanel>
<TabControl> <TabControl>
<TabItem Header="Single"> <TabItem Header="Single">
<StackPanel> <StackPanel>
<ScrollViewer HorizontalScrollBarVisibility="{Binding HorizontalVisibility}" VerticalScrollBarVisibility="{Binding VerticalVisibility}"> <ScrollViewer HorizontalScrollBarVisibility="{Binding HorizontalVisibility}"
VerticalScrollBarVisibility="{Binding VerticalVisibility}">
<DockPanel> <DockPanel>
<Label Background="{DynamicResource SemiPurple2Color}" <Label Background="{DynamicResource SemiPurple2Color}"
Content="WrapPanel" Content="WrapPanel"
@@ -183,27 +191,33 @@
<WrapPanel ItemHeight="{Binding ItemHeight}" <WrapPanel ItemHeight="{Binding ItemHeight}"
ItemWidth="{Binding ItemWidth}" ItemWidth="{Binding ItemWidth}"
Orientation="{Binding SelectedOrientation}"> Orientation="{Binding SelectedOrientation}">
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 1" /> <TextBlock VerticalAlignment="Center" Text="Content 1" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 2" /> <TextBlock VerticalAlignment="Center" Text="Content 2" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 3" /> <TextBlock VerticalAlignment="Center" Text="Content 3" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 4" /> <TextBlock VerticalAlignment="Center" Text="Content 4" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 5" /> <TextBlock VerticalAlignment="Center" Text="Content 5" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 6" /> <TextBlock VerticalAlignment="Center" Text="Content 6" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
@@ -223,7 +237,8 @@
</WrapPanel> </WrapPanel>
</DockPanel> </DockPanel>
</ScrollViewer> </ScrollViewer>
<ScrollViewer HorizontalScrollBarVisibility="{Binding HorizontalVisibility}" VerticalScrollBarVisibility="{Binding VerticalVisibility}"> <ScrollViewer HorizontalScrollBarVisibility="{Binding HorizontalVisibility}"
VerticalScrollBarVisibility="{Binding VerticalVisibility}">
<DockPanel> <DockPanel>
<Label Background="{DynamicResource SemiGreen2Color}" <Label Background="{DynamicResource SemiGreen2Color}"
Content="ElasticWrapPanel" Content="ElasticWrapPanel"
@@ -233,27 +248,33 @@
ItemHeight="{Binding ItemHeight}" ItemHeight="{Binding ItemHeight}"
ItemWidth="{Binding ItemWidth}" ItemWidth="{Binding ItemWidth}"
Orientation="{Binding SelectedOrientation}"> Orientation="{Binding SelectedOrientation}">
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 1" /> <TextBlock VerticalAlignment="Center" Text="Content 1" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 2" /> <TextBlock VerticalAlignment="Center" Text="Content 2" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 3" /> <TextBlock VerticalAlignment="Center" Text="Content 3" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 4" /> <TextBlock VerticalAlignment="Center" Text="Content 4" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 5" /> <TextBlock VerticalAlignment="Center" Text="Content 5" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 6" /> <TextBlock VerticalAlignment="Center" Text="Content 6" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
@@ -277,7 +298,8 @@
</TabItem> </TabItem>
<TabItem Header="Multiply"> <TabItem Header="Multiply">
<StackPanel> <StackPanel>
<ScrollViewer HorizontalScrollBarVisibility="{Binding HorizontalVisibility}" VerticalScrollBarVisibility="{Binding VerticalVisibility}"> <ScrollViewer HorizontalScrollBarVisibility="{Binding HorizontalVisibility}"
VerticalScrollBarVisibility="{Binding VerticalVisibility}">
<DockPanel> <DockPanel>
<Label Background="{DynamicResource SemiPurple2Color}" <Label Background="{DynamicResource SemiPurple2Color}"
Content="WrapPanel" Content="WrapPanel"
@@ -285,27 +307,33 @@
<WrapPanel ItemHeight="{Binding ItemHeight}" <WrapPanel ItemHeight="{Binding ItemHeight}"
ItemWidth="{Binding ItemWidth}" ItemWidth="{Binding ItemWidth}"
Orientation="{Binding SelectedOrientation}"> Orientation="{Binding SelectedOrientation}">
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 1" /> <TextBlock VerticalAlignment="Center" Text="Content 1" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 2" /> <TextBlock VerticalAlignment="Center" Text="Content 2" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 3" /> <TextBlock VerticalAlignment="Center" Text="Content 3" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 4" /> <TextBlock VerticalAlignment="Center" Text="Content 4" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 5" /> <TextBlock VerticalAlignment="Center" Text="Content 5" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 6" /> <TextBlock VerticalAlignment="Center" Text="Content 6" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
@@ -322,27 +350,33 @@
Margin="1" Margin="1"
Content="Export" /> Content="Export" />
</UniformGrid> </UniformGrid>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 1" /> <TextBlock VerticalAlignment="Center" Text="Content 1" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 2" /> <TextBlock VerticalAlignment="Center" Text="Content 2" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 3" /> <TextBlock VerticalAlignment="Center" Text="Content 3" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 4" /> <TextBlock VerticalAlignment="Center" Text="Content 4" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 5" /> <TextBlock VerticalAlignment="Center" Text="Content 5" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 6" /> <TextBlock VerticalAlignment="Center" Text="Content 6" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
@@ -362,7 +396,8 @@
</WrapPanel> </WrapPanel>
</DockPanel> </DockPanel>
</ScrollViewer> </ScrollViewer>
<ScrollViewer HorizontalScrollBarVisibility="{Binding HorizontalVisibility}" VerticalScrollBarVisibility="{Binding VerticalVisibility}"> <ScrollViewer HorizontalScrollBarVisibility="{Binding HorizontalVisibility}"
VerticalScrollBarVisibility="{Binding VerticalVisibility}">
<DockPanel> <DockPanel>
<Label Background="{DynamicResource SemiGreen2Color}" <Label Background="{DynamicResource SemiGreen2Color}"
Content="ElasticWrapPanel" Content="ElasticWrapPanel"
@@ -372,27 +407,33 @@
ItemHeight="{Binding ItemHeight}" ItemHeight="{Binding ItemHeight}"
ItemWidth="{Binding ItemWidth}" ItemWidth="{Binding ItemWidth}"
Orientation="{Binding SelectedOrientation}"> Orientation="{Binding SelectedOrientation}">
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 1" /> <TextBlock VerticalAlignment="Center" Text="Content 1" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 2" /> <TextBlock VerticalAlignment="Center" Text="Content 2" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 3" /> <TextBlock VerticalAlignment="Center" Text="Content 3" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 4" /> <TextBlock VerticalAlignment="Center" Text="Content 4" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 5" /> <TextBlock VerticalAlignment="Center" Text="Content 5" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 6" /> <TextBlock VerticalAlignment="Center" Text="Content 6" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
@@ -409,27 +450,33 @@
Margin="1" Margin="1"
Content="Export" /> Content="Export" />
</UniformGrid> </UniformGrid>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 1" /> <TextBlock VerticalAlignment="Center" Text="Content 1" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 2" /> <TextBlock VerticalAlignment="Center" Text="Content 2" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 3" /> <TextBlock VerticalAlignment="Center" Text="Content 3" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 4" /> <TextBlock VerticalAlignment="Center" Text="Content 4" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 5" /> <TextBlock VerticalAlignment="Center" Text="Content 5" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>
<DockPanel Width="{Binding ItemSelfWidth}" Height="{Binding ItemSelfHeight}"> <DockPanel Width="{Binding ItemSelfWidth}"
Height="{Binding ItemSelfHeight}">
<TextBlock VerticalAlignment="Center" Text="Content 6" /> <TextBlock VerticalAlignment="Center" Text="Content 6" />
<TextBox MinHeight="20" /> <TextBox MinHeight="20" />
</DockPanel> </DockPanel>

View File

@@ -7,63 +7,79 @@ namespace Ursa.Demo.ViewModels;
public partial class ElasticWrapPanelDemoViewModel : ObservableObject public partial class ElasticWrapPanelDemoViewModel : ObservableObject
{ {
[ObservableProperty] private Orientation _selectedOrientation; [ObservableProperty]
[ObservableProperty] private ScrollBarVisibility _horizontalVisibility; private ObservableCollection<Orientation> _orientations = [Orientation.Horizontal, Orientation.Vertical];
[ObservableProperty] private ScrollBarVisibility _verticalVisibility;
[ObservableProperty] private ObservableCollection<Orientation> _orientations = null!;
[ObservableProperty] private ObservableCollection<ScrollBarVisibility> _hScrollBarVisibilities = null!;
[ObservableProperty] private ObservableCollection<ScrollBarVisibility> _vScrollBarVisibilities = null!;
[ObservableProperty] private bool _isFillHorizontal; [ObservableProperty] private Orientation _selectedOrientation = Orientation.Horizontal;
[ObservableProperty] private bool _isFillVertical;
[ObservableProperty] private double? _itemWidth;
[ObservableProperty] private double? _itemHeight;
[ObservableProperty] private double? _itemSelfWidth; [ObservableProperty] private ObservableCollection<ScrollBarVisibility> _hScrollBarVisibilities =
[ObservableProperty] private double? _itemSelfHeight; [
ScrollBarVisibility.Disabled, ScrollBarVisibility.Auto, ScrollBarVisibility.Hidden, ScrollBarVisibility.Visible
];
[ObservableProperty] private HorizontalAlignment _cmbHAlign; [ObservableProperty] private ObservableCollection<ScrollBarVisibility> _vScrollBarVisibilities =
[ObservableProperty] private VerticalAlignment _cmbVAlign; [
[ObservableProperty] private ObservableCollection<HorizontalAlignment> _cmbHAligns = null!; ScrollBarVisibility.Disabled, ScrollBarVisibility.Auto, ScrollBarVisibility.Hidden, ScrollBarVisibility.Visible
[ObservableProperty] private ObservableCollection<VerticalAlignment> _cmbVAligns = null!; ];
public ElasticWrapPanelDemoViewModel() [ObservableProperty] private ScrollBarVisibility _horizontalVisibility = ScrollBarVisibility.Auto;
[ObservableProperty] private ScrollBarVisibility _verticalVisibility = ScrollBarVisibility.Auto;
[ObservableProperty] private bool _isFillHorizontal = true;
[ObservableProperty] private bool _isFillVertical = false;
[ObservableProperty] private double _itemWidth = 40d;
[ObservableProperty] private double _itemHeight = 40d;
[ObservableProperty] private bool _autoWidth;
[ObservableProperty] private bool _autoHeight;
[ObservableProperty] private double _itemSelfWidth = double.NaN;
[ObservableProperty] private double _itemSelfHeight = double.NaN;
[ObservableProperty] private ObservableCollection<HorizontalAlignment> _cmbHAligns =
[
HorizontalAlignment.Stretch,
HorizontalAlignment.Left,
HorizontalAlignment.Center,
HorizontalAlignment.Right
];
[ObservableProperty] private ObservableCollection<VerticalAlignment> _cmbVAligns =
[
VerticalAlignment.Stretch,
VerticalAlignment.Top,
VerticalAlignment.Center,
VerticalAlignment.Bottom
];
[ObservableProperty] private HorizontalAlignment _cmbHAlign = HorizontalAlignment.Stretch;
[ObservableProperty] private VerticalAlignment _cmbVAlign = VerticalAlignment.Stretch;
private double _oldItemSelfWidth;
private double _oldItemSelfHeight;
partial void OnAutoWidthChanged(bool value)
{ {
SelectedOrientation = Orientation.Horizontal; if (value)
HorizontalVisibility = VerticalVisibility = ScrollBarVisibility.Auto;
Orientations = new ObservableCollection<Orientation>() { Orientation.Horizontal, Orientation.Vertical };
HScrollBarVisibilities = new ObservableCollection<ScrollBarVisibility>()
{ {
ScrollBarVisibility.Disabled, _oldItemSelfWidth = ItemSelfWidth;
ScrollBarVisibility.Auto, ItemSelfWidth = double.NaN;
ScrollBarVisibility.Hidden, }
ScrollBarVisibility.Visible else
};
VScrollBarVisibilities = new ObservableCollection<ScrollBarVisibility>(HScrollBarVisibilities);
IsFillHorizontal = true;
IsFillVertical = false;
ItemWidth = 40d;
ItemHeight = 40d;
ItemSelfWidth = double.NaN;
ItemSelfHeight = double.NaN;
CmbHAligns = new ObservableCollection<HorizontalAlignment>()
{ {
HorizontalAlignment.Stretch, ItemSelfWidth = _oldItemSelfWidth;
HorizontalAlignment.Left, }
HorizontalAlignment.Center, }
HorizontalAlignment.Right
}; partial void OnAutoHeightChanged(bool value)
CmbVAligns = new ObservableCollection<VerticalAlignment>() {
if (value)
{ {
VerticalAlignment.Stretch, _oldItemSelfHeight = ItemSelfHeight;
VerticalAlignment.Top, ItemSelfHeight = double.NaN;
VerticalAlignment.Center, }
VerticalAlignment.Bottom else
}; {
CmbHAlign = HorizontalAlignment.Stretch; ItemSelfHeight = _oldItemSelfHeight;
CmbVAlign = VerticalAlignment.Stretch; }
} }
} }