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"
LabelWidth="*">
<u:FormGroup>
<u:FormItem Label="Orientation">
<ComboBox ItemsSource="{Binding Orientations}" SelectedItem="{Binding SelectedOrientation}" /> <ComboBox ItemsSource="{Binding Orientations}" SelectedItem="{Binding SelectedOrientation}" />
<TextBlock Text="HorizontalScrollBar" /> </u:FormItem>
<ComboBox ItemsSource="{Binding HScrollBarVisibilities}" SelectedItem="{Binding HorizontalVisibility}" /> <u:FormItem Label="HorizontalScrollBar">
<TextBlock Text="VerticalScrollBar" /> <ComboBox ItemsSource="{Binding HScrollBarVisibilities}"
<ComboBox ItemsSource="{Binding VScrollBarVisibilities}" SelectedItem="{Binding VerticalVisibility}" /> SelectedItem="{Binding HorizontalVisibility}" />
</StackPanel> </u:FormItem>
<StackPanel Orientation="Horizontal"> <u:FormItem Label="VerticalScrollBar">
<ComboBox ItemsSource="{Binding VScrollBarVisibilities}"
SelectedIndex="{Binding VerticalVisibility}" />
</u:FormItem>
<u:FormItem>
<u:FormItem.Label>
<CheckBox Content="IsFillHorizontal" IsChecked="{Binding IsFillHorizontal}" /> <CheckBox Content="IsFillHorizontal" IsChecked="{Binding IsFillHorizontal}" />
<TextBlock Text="ItemWidth" /> </u:FormItem.Label>
<NumericUpDown Increment="1" <u:NumericDoubleUpDown
InnerLeftContent="ItemWidth"
Step="1"
AllowDrag="True"
Maximum="1000" Maximum="1000"
Minimum="0" Minimum="0"
Value="{Binding ItemWidth}" /> Value="{Binding ItemWidth}" />
</StackPanel> </u:FormItem>
<StackPanel Orientation="Horizontal"> <u:FormItem>
<u:FormItem.Label>
<CheckBox Content="IsFillVertical" IsChecked="{Binding IsFillVertical}" /> <CheckBox Content="IsFillVertical" IsChecked="{Binding IsFillVertical}" />
<TextBlock Text="ItemHeight" /> </u:FormItem.Label>
<NumericUpDown Increment="1" <u:NumericDoubleUpDown
InnerLeftContent="ItemHeight"
AllowDrag="True"
Step="1"
Maximum="1000" Maximum="1000"
Minimum="0" Minimum="0"
Value="{Binding ItemHeight}" /> Value="{Binding ItemHeight}" />
</StackPanel> </u:FormItem>
<StackPanel.Styles> </u:FormGroup>
<Style Selector="StackPanel#ControlBar &gt; StackPanel &gt; TextBlock"> <u:FormGroup Header="FixToRB Extension" IsEnabled="{Binding #FixToRBTabItem.IsSelected}">
<Setter Property="VerticalAlignment" Value="Center" /> <u:FormItem>
<Setter Property="Margin" Value="10 0" /> <u:FormItem.Label>
</Style> <CheckBox Content="AutoWidth" IsChecked="{Binding AutoWidth}" />
<Style Selector="StackPanel#ControlBar &gt; StackPanel &gt; TextBox, NumericUpDown"> </u:FormItem.Label>
<Setter Property="Width" Value="100" /> <u:NumericDoubleUpDown
</Style> AllowDrag="True"
<Style Selector="StackPanel#ControlBar &gt; StackPanel &gt; ComboBox"> Maximum="1000"
<Setter Property="Width" Value="130" /> Minimum="0"
</Style> IsEnabled="{Binding !AutoWidth}"
</StackPanel.Styles> Value="{Binding ItemSelfWidth}" />
</StackPanel> </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;
SelectedOrientation = Orientation.Horizontal;
HorizontalVisibility = VerticalVisibility = ScrollBarVisibility.Auto;
Orientations = new ObservableCollection<Orientation>() { Orientation.Horizontal, Orientation.Vertical };
HScrollBarVisibilities = new ObservableCollection<ScrollBarVisibility>()
{
ScrollBarVisibility.Disabled,
ScrollBarVisibility.Auto,
ScrollBarVisibility.Hidden,
ScrollBarVisibility.Visible
};
VScrollBarVisibilities = new ObservableCollection<ScrollBarVisibility>(HScrollBarVisibilities);
IsFillHorizontal = true; [ObservableProperty] private bool _isFillHorizontal = true;
IsFillVertical = false; [ObservableProperty] private bool _isFillVertical = false;
ItemWidth = 40d; [ObservableProperty] private double _itemWidth = 40d;
ItemHeight = 40d; [ObservableProperty] private double _itemHeight = 40d;
ItemSelfWidth = double.NaN; [ObservableProperty] private bool _autoWidth;
ItemSelfHeight = double.NaN; [ObservableProperty] private bool _autoHeight;
[ObservableProperty] private double _itemSelfWidth = double.NaN;
[ObservableProperty] private double _itemSelfHeight = double.NaN;
CmbHAligns = new ObservableCollection<HorizontalAlignment>() [ObservableProperty] private ObservableCollection<HorizontalAlignment> _cmbHAligns =
{ [
HorizontalAlignment.Stretch, HorizontalAlignment.Stretch,
HorizontalAlignment.Left, HorizontalAlignment.Left,
HorizontalAlignment.Center, HorizontalAlignment.Center,
HorizontalAlignment.Right HorizontalAlignment.Right
}; ];
CmbVAligns = new ObservableCollection<VerticalAlignment>()
{ [ObservableProperty] private ObservableCollection<VerticalAlignment> _cmbVAligns =
[
VerticalAlignment.Stretch, VerticalAlignment.Stretch,
VerticalAlignment.Top, VerticalAlignment.Top,
VerticalAlignment.Center, VerticalAlignment.Center,
VerticalAlignment.Bottom VerticalAlignment.Bottom
}; ];
CmbHAlign = HorizontalAlignment.Stretch;
CmbVAlign = VerticalAlignment.Stretch; [ObservableProperty] private HorizontalAlignment _cmbHAlign = HorizontalAlignment.Stretch;
[ObservableProperty] private VerticalAlignment _cmbVAlign = VerticalAlignment.Stretch;
private double _oldItemSelfWidth;
private double _oldItemSelfHeight;
partial void OnAutoWidthChanged(bool value)
{
if (value)
{
_oldItemSelfWidth = ItemSelfWidth;
ItemSelfWidth = double.NaN;
}
else
{
ItemSelfWidth = _oldItemSelfWidth;
}
}
partial void OnAutoHeightChanged(bool value)
{
if (value)
{
_oldItemSelfHeight = ItemSelfHeight;
ItemSelfHeight = double.NaN;
}
else
{
ItemSelfHeight = _oldItemSelfHeight;
}
} }
} }