feat: demo page.

This commit is contained in:
Zhang Dian
2023-09-18 13:12:28 +08:00
parent ef4d871bcf
commit 2d15767f00
2 changed files with 645 additions and 7 deletions

View File

@@ -5,8 +5,646 @@
xmlns:u="https://irihi.tech/ursa"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Ursa.Demo.Pages.ElasticWrapPanelDemo">
<u:ElasticWrapPanel>
<TextBlock Text="Rua ta ta"/>
<TextBlock Text="320"/>
</u:ElasticWrapPanel>
<Grid>
<DockPanel>
<TextBlock Text="一个优化奇怪的WrapPanel" DockPanel.Dock="Top" FontWeight="Bold" />
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
<TextBlock Text="排列方式" VerticalAlignment="Center" />
<ComboBox x:Name="CmbOrientation" Width="90" SelectedIndex="1">
<Orientation>Vertical</Orientation>
<Orientation>Horizontal</Orientation>
</ComboBox>
<TextBlock Text="水平滚动条" VerticalAlignment="Center" />
<ComboBox x:Name="ScrollViewHVisb" Width="90" SelectedIndex="0">
<ScrollBarVisibility>Auto</ScrollBarVisibility>
<ScrollBarVisibility>Disabled</ScrollBarVisibility>
<ScrollBarVisibility>Hidden</ScrollBarVisibility>
<ScrollBarVisibility>Visible</ScrollBarVisibility>
</ComboBox>
<TextBlock Text="垂直滚动条" VerticalAlignment="Center" />
<ComboBox x:Name="ScrollViewVVisb" Width="90" SelectedIndex="0">
<ScrollBarVisibility>Auto</ScrollBarVisibility>
<ScrollBarVisibility>Disabled</ScrollBarVisibility>
<ScrollBarVisibility>Hidden</ScrollBarVisibility>
<ScrollBarVisibility>Visible</ScrollBarVisibility>
</ComboBox>
</StackPanel>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
<CheckBox x:Name="chkFillWidth" IsChecked="True" Content="水平平铺"
VerticalAlignment="Center" VerticalContentAlignment="Center"
Margin="0,0,10,0" />
<TextBlock Text="宽度" VerticalAlignment="Center" />
<Grid>
<!-- <Rectangle x:Name="Rect1" Width="100" Visibility="Collapsed" /> -->
<Rectangle x:Name="Rect1" Width="100" />
<TextBox x:Name="txtItemWidth" MinWidth="60" Height="22" VerticalContentAlignment="Center"
Text="{Binding ElementName=Rect1,Path=Width,Mode=TwoWay}" />
</Grid>
<CheckBox x:Name="chkFillHeight" IsChecked="True" Content="垂直平铺"
VerticalAlignment="Center" VerticalContentAlignment="Center"
Margin="0,0,10,0" />
<TextBlock Text="高度" VerticalAlignment="Center" />
<Grid>
<TextBox x:Name="txtItemHeight" MinWidth="60" Height="22" VerticalContentAlignment="Center"
Text="{Binding ElementName=Rect1,Path=Height,Mode=TwoWay}" />
</Grid>
<TextBlock Text="* 数字可填入NaN" Foreground="Red" VerticalAlignment="Center" />
</StackPanel>
<TabControl>
<TabItem Header="平铺Demo">
<TabControl>
<TabItem Header="情景1高度充满">
<u:ElasticWrapPanel x:Name="ElasticWrapPanel" Grid.Row="3"
IsFillHorizontal="{Binding ElementName=chkFillWidth,Path=IsChecked,Mode=TwoWay}"
IsFillVertical="{Binding ElementName=chkFillHeight,Path=IsChecked,Mode=TwoWay}"
ItemWidth="{Binding ElementName=Rect1,Path=Width}"
ItemHeight="{Binding ElementName=Rect1,Path=Height}"
Orientation="{Binding ElementName=CmbOrientation,Path=SelectedValue}">
<DockPanel MinHeight="35" Margin="0,0,5,2">
<DockPanel.Background>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="#FFA6A6A6" Offset="0" />
<GradientStop Color="#FFCFCFCF" Offset="1" />
</LinearGradientBrush>
</DockPanel.Background>
<Rectangle Fill="#F05033" Width="4" />
<Grid Margin="5">
<Ellipse StrokeThickness="2" Width="25" Height="25" Stroke="Black" />
<Ellipse StrokeThickness="2" Width="17" Height="17" Fill="#FFB8B2B2" />
</Grid>
<TextBlock Text="Changed" FontWeight="Medium" FontSize="16"
VerticalAlignment="Center" />
</DockPanel>
<DockPanel MinHeight="35" Margin="0,0,5,2">
<DockPanel.Background>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="#FFA6A6A6" Offset="0" />
<GradientStop Color="#FFCFCFCF" Offset="1" />
</LinearGradientBrush>
</DockPanel.Background>
<Rectangle Fill="#F05033" Width="4" />
<Grid Margin="5">
<Ellipse StrokeThickness="2" Width="25" Height="25" Stroke="Black" />
<Ellipse StrokeThickness="2" Width="17" Height="17" Fill="#FFDCA1A1" />
</Grid>
<TextBlock Text="Branches" FontWeight="Medium" FontSize="16"
VerticalAlignment="Center" />
</DockPanel>
<DockPanel MinHeight="35" Margin="0,0,5,2">
<DockPanel.Background>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="#FFA6A6A6" Offset="0" />
<GradientStop Color="#FFCFCFCF" Offset="1" />
</LinearGradientBrush>
</DockPanel.Background>
<Rectangle Fill="#FF3333F0" Width="4" />
<Grid Margin="5">
<Ellipse StrokeThickness="2" Width="25" Height="25" Stroke="Black" />
<Ellipse StrokeThickness="2" Width="17" Height="17" Fill="#FFB5B9BD" />
</Grid>
<TextBlock Text="Sync" FontWeight="Medium" FontSize="16" VerticalAlignment="Center" />
</DockPanel>
<DockPanel MinHeight="35" Margin="0,0,5,2">
<DockPanel.Background>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="#FFA6A6A6" Offset="0" />
<GradientStop Color="#FFCFCFCF" Offset="1" />
</LinearGradientBrush>
</DockPanel.Background>
<Rectangle Fill="#FF616161" Width="4" />
<Grid Margin="5">
<Ellipse StrokeThickness="2" Width="25" Height="25" Stroke="Black" />
<Ellipse StrokeThickness="2" Width="17" Height="17" Fill="#FF3E3E3E" />
</Grid>
<TextBlock Text="Setting" FontWeight="Medium" FontSize="16"
VerticalAlignment="Center" />
</DockPanel>
<DockPanel MinHeight="35" Margin="0,0,5,2">
<DockPanel.Background>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="#FFA6A6A6" Offset="0" />
<GradientStop Color="#FF555E85" Offset="1" />
</LinearGradientBrush>
</DockPanel.Background>
<Rectangle Fill="#FF616161" Width="4" />
<Grid Margin="5">
<Ellipse StrokeThickness="2" Width="25" Height="25" Stroke="Black" />
<Ellipse StrokeThickness="2" Width="17" Height="17" Fill="#FF93B6AA" />
</Grid>
<TextBlock Text="Others" FontWeight="Medium" FontSize="16"
VerticalAlignment="Center" />
</DockPanel>
</u:ElasticWrapPanel>
</TabItem>
<TabItem Header="情景2高度Auto">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition />
</Grid.RowDefinitions>
<u:ElasticWrapPanel
IsFillHorizontal="{Binding ElementName=chkFillWidth,Path=IsChecked,Mode=TwoWay}"
IsFillVertical="{Binding ElementName=chkFillHeight,Path=IsChecked,Mode=TwoWay}"
ItemWidth="{Binding ElementName=Rect1,Path=Width}"
ItemHeight="{Binding ElementName=Rect1,Path=Height}"
Orientation="{Binding ElementName=CmbOrientation,Path=SelectedValue}">
<DockPanel MinHeight="35" Margin="0,0,5,2">
<DockPanel.Background>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="#FFA6A6A6" Offset="0" />
<GradientStop Color="#FFCFCFCF" Offset="1" />
</LinearGradientBrush>
</DockPanel.Background>
<Rectangle Fill="#F05033" Width="4" />
<Grid Margin="5">
<Ellipse StrokeThickness="2" Width="25" Height="25" Stroke="Black" />
<Ellipse StrokeThickness="2" Width="17" Height="17" Fill="#FFB8B2B2" />
</Grid>
<TextBlock Text="Changed" FontWeight="Medium" FontSize="16"
VerticalAlignment="Center" />
</DockPanel>
<DockPanel MinHeight="35" Margin="0,0,5,2">
<DockPanel.Background>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="#FFA6A6A6" Offset="0" />
<GradientStop Color="#FFCFCFCF" Offset="1" />
</LinearGradientBrush>
</DockPanel.Background>
<Rectangle Fill="#F05033" Width="4" />
<Grid Margin="5">
<Ellipse StrokeThickness="2" Width="25" Height="25" Stroke="Black" />
<Ellipse StrokeThickness="2" Width="17" Height="17" Fill="#FFDCA1A1" />
</Grid>
<TextBlock Text="Branches" FontWeight="Medium" FontSize="16"
VerticalAlignment="Center" />
</DockPanel>
<DockPanel MinHeight="35" Margin="0,0,5,2">
<DockPanel.Background>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="#FFA6A6A6" Offset="0" />
<GradientStop Color="#FFCFCFCF" Offset="1" />
</LinearGradientBrush>
</DockPanel.Background>
<Rectangle Fill="#FF3333F0" Width="4" />
<Grid Margin="5">
<Ellipse StrokeThickness="2" Width="25" Height="25" Stroke="Black" />
<Ellipse StrokeThickness="2" Width="17" Height="17" Fill="#FFB5B9BD" />
</Grid>
<TextBlock Text="Sync" FontWeight="Medium" FontSize="16"
VerticalAlignment="Center" />
</DockPanel>
<DockPanel MinHeight="35" Margin="0,0,5,2">
<DockPanel.Background>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="#FFA6A6A6" Offset="0" />
<GradientStop Color="#FFCFCFCF" Offset="1" />
</LinearGradientBrush>
</DockPanel.Background>
<Rectangle Fill="#FF616161" Width="4" />
<Grid Margin="5">
<Ellipse StrokeThickness="2" Width="25" Height="25" Stroke="Black" />
<Ellipse StrokeThickness="2" Width="17" Height="17" Fill="#FF3E3E3E" />
</Grid>
<TextBlock Text="Setting" FontWeight="Medium" FontSize="16"
VerticalAlignment="Center" />
</DockPanel>
<DockPanel MinHeight="35" Margin="0,0,5,2">
<DockPanel.Background>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="#FFA6A6A6" Offset="0" />
<GradientStop Color="#FF555E85" Offset="1" />
</LinearGradientBrush>
</DockPanel.Background>
<Rectangle Fill="#FF616161" Width="4" />
<Grid Margin="5">
<Ellipse StrokeThickness="2" Width="25" Height="25" Stroke="Black" />
<Ellipse StrokeThickness="2" Width="17" Height="17" Fill="#FF93B6AA" />
</Grid>
<TextBlock Text="Others" FontWeight="Medium" FontSize="16"
VerticalAlignment="Center" />
</DockPanel>
</u:ElasticWrapPanel>
<Border Grid.Row="1" BorderThickness="1" BorderBrush="Red" Margin="0,4">
<Label Content="这里是VS扩展git源码提交部分界面不实现" />
</Border>
</Grid>
</TabItem>
<TabItem Header="情景3(ScrollView中表现)">
<Border Grid.Row="3" Margin="70,30" BorderBrush="Red" BorderThickness="1">
<ScrollViewer
HorizontalScrollBarVisibility="{Binding ElementName=ScrollViewHVisb,Path=SelectedValue}"
VerticalScrollBarVisibility="{Binding ElementName=ScrollViewVVisb,Path=SelectedValue}">
<u:ElasticWrapPanel x:Name="ElasticWrapPanel3"
IsFillHorizontal="{Binding ElementName=chkFillWidth,Path=IsChecked,Mode=TwoWay}"
IsFillVertical="{Binding ElementName=chkFillHeight,Path=IsChecked,Mode=TwoWay}"
ItemWidth="{Binding ElementName=Rect1,Path=Width}"
ItemHeight="{Binding ElementName=Rect1,Path=Height}"
Orientation="{Binding ElementName=CmbOrientation,Path=SelectedValue}">
<DockPanel MinHeight="35" Margin="0,0,5,2">
<DockPanel.Background>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="#FFA6A6A6" Offset="0" />
<GradientStop Color="#FFCFCFCF" Offset="1" />
</LinearGradientBrush>
</DockPanel.Background>
<Rectangle Fill="#F05033" Width="4" />
<Grid Margin="5">
<Ellipse StrokeThickness="2" Width="25" Height="25" Stroke="Black" />
<Ellipse StrokeThickness="2" Width="17" Height="17" Fill="#FFB8B2B2" />
</Grid>
<TextBlock Text="Changed" FontWeight="Medium" FontSize="16"
VerticalAlignment="Center" />
</DockPanel>
<DockPanel MinHeight="35" Margin="0,0,5,2">
<DockPanel.Background>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="#FFA6A6A6" Offset="0" />
<GradientStop Color="#FFCFCFCF" Offset="1" />
</LinearGradientBrush>
</DockPanel.Background>
<Rectangle Fill="#F05033" Width="4" />
<Grid Margin="5">
<Ellipse StrokeThickness="2" Width="25" Height="25" Stroke="Black" />
<Ellipse StrokeThickness="2" Width="17" Height="17" Fill="#FFDCA1A1" />
</Grid>
<TextBlock Text="Branches" FontWeight="Medium" FontSize="16"
VerticalAlignment="Center" />
</DockPanel>
<DockPanel MinHeight="35" Margin="0,0,5,2">
<DockPanel.Background>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="#FFA6A6A6" Offset="0" />
<GradientStop Color="#FFCFCFCF" Offset="1" />
</LinearGradientBrush>
</DockPanel.Background>
<Rectangle Fill="#FF3333F0" Width="4" />
<Grid Margin="5">
<Ellipse StrokeThickness="2" Width="25" Height="25" Stroke="Black" />
<Ellipse StrokeThickness="2" Width="17" Height="17" Fill="#FFB5B9BD" />
</Grid>
<TextBlock Text="Sync" FontWeight="Medium" FontSize="16"
VerticalAlignment="Center" />
</DockPanel>
<DockPanel MinHeight="35" Margin="0,0,5,2">
<DockPanel.Background>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="#FFA6A6A6" Offset="0" />
<GradientStop Color="#FFCFCFCF" Offset="1" />
</LinearGradientBrush>
</DockPanel.Background>
<Rectangle Fill="#FF616161" Width="4" />
<Grid Margin="5">
<Ellipse StrokeThickness="2" Width="25" Height="25" Stroke="Black" />
<Ellipse StrokeThickness="2" Width="17" Height="17" Fill="#FF3E3E3E" />
</Grid>
<TextBlock Text="Setting" FontWeight="Medium" FontSize="16"
VerticalAlignment="Center" />
</DockPanel>
<DockPanel MinHeight="35" Margin="0,0,5,2">
<DockPanel.Background>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="#FFA6A6A6" Offset="0" />
<GradientStop Color="#FF555E85" Offset="1" />
</LinearGradientBrush>
</DockPanel.Background>
<Rectangle Fill="#FF616161" Width="4" />
<Grid Margin="5">
<Ellipse StrokeThickness="2" Width="25" Height="25" Stroke="Black" />
<Ellipse StrokeThickness="2" Width="17" Height="17" Fill="#FF93B6AA" />
</Grid>
<TextBlock Text="Others" FontWeight="Medium" FontSize="16"
VerticalAlignment="Center" />
</DockPanel>
</u:ElasticWrapPanel>
</ScrollViewer>
</Border>
</TabItem>
</TabControl>
</TabItem>
<TabItem Header="平铺+靠右">
<DockPanel>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
<TextBlock Text="输入控件宽度" VerticalAlignment="Center" />
<Grid>
<Rectangle x:Name="Rect2" />
<TextBox MinWidth="60" Height="22" VerticalContentAlignment="Center"
Text="{Binding ElementName=Rect2,Path=Width,Mode=TwoWay}" />
</Grid>
<TextBlock Text="输入控件高度" VerticalAlignment="Center" />
<Grid>
<TextBox MinWidth="60" Height="22" VerticalContentAlignment="Center"
Text="{Binding ElementName=Rect2,Path=Height,Mode=TwoWay}" />
</Grid>
<ComboBox x:Name="cmbVerAlig" SelectedIndex="3" Width="70">
<VerticalAlignment>Top</VerticalAlignment>
<VerticalAlignment>Center</VerticalAlignment>
<VerticalAlignment>Bottom</VerticalAlignment>
<VerticalAlignment>Stretch</VerticalAlignment>
</ComboBox>
<ComboBox x:Name="cmbHorAlig" SelectedIndex="3" Width="70">
<HorizontalAlignment>Left</HorizontalAlignment>
<HorizontalAlignment>Center</HorizontalAlignment>
<HorizontalAlignment>Right</HorizontalAlignment>
<HorizontalAlignment>Stretch</HorizontalAlignment>
</ComboBox>
</StackPanel>
<TabControl>
<TabItem Header="一个">
<StackPanel x:Name="UnifornGrid1">
<ScrollViewer
HorizontalScrollBarVisibility="{Binding ElementName=ScrollViewHVisb,Path=SelectedValue}"
VerticalScrollBarVisibility="{Binding ElementName=ScrollViewVVisb,Path=SelectedValue}">
<DockPanel>
<Label Content="WrapPanel" Background="#FFCBCBEA" DockPanel.Dock="Top" />
<WrapPanel ItemWidth="{Binding ElementName=Rect1,Path=Width}"
ItemHeight="{Binding ElementName=Rect1,Path=Height}"
Orientation="{Binding ElementName=CmbOrientation,Path=SelectedValue}">
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容1" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容2" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容3" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容4" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容5" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容6" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<UniformGrid Rows="1" Margin="5,0" MinWidth="200"
u:ElasticWrapPanel.FixToRB="True"
HorizontalAlignment="{Binding ElementName=cmbHorAlig,Path=SelectedValue}"
VerticalAlignment="{Binding ElementName=cmbVerAlig,Path=SelectedValue}">
<Button Content="查询" MinHeight="22" Margin="1" />
<Button Content="导出" MinHeight="22" Margin="1" />
</UniformGrid>
</WrapPanel>
</DockPanel>
</ScrollViewer>
<ScrollViewer
HorizontalScrollBarVisibility="{Binding ElementName=ScrollViewHVisb,Path=SelectedValue}"
VerticalScrollBarVisibility="{Binding ElementName=ScrollViewVVisb,Path=SelectedValue}">
<DockPanel>
<Label Content="ElasticWrapPanel" Background="#FFB4F1AA" DockPanel.Dock="Top" />
<u:ElasticWrapPanel
IsFillHorizontal="{Binding ElementName=chkFillWidth,Path=IsChecked,Mode=TwoWay}"
IsFillVertical="{Binding ElementName=chkFillHeight,Path=IsChecked,Mode=TwoWay}"
ItemWidth="{Binding ElementName=Rect1,Path=Width}"
ItemHeight="{Binding ElementName=Rect1,Path=Height}"
Orientation="{Binding ElementName=CmbOrientation,Path=SelectedValue}">
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容1" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容2" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容3" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容4" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容5" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容6" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<UniformGrid Rows="1" Margin="5,0" MinWidth="200"
u:ElasticWrapPanel.FixToRB="True"
HorizontalAlignment="{Binding ElementName=cmbHorAlig,Path=SelectedValue}"
VerticalAlignment="{Binding ElementName=cmbVerAlig,Path=SelectedValue}">
<Button Content="查询" MinHeight="22" Margin="1" />
<Button Content="导出" MinHeight="22" Margin="1" />
</UniformGrid>
</u:ElasticWrapPanel>
</DockPanel>
</ScrollViewer>
</StackPanel>
</TabItem>
<TabItem Header="多个">
<StackPanel x:Name="UnifornGrid2">
<ScrollViewer
HorizontalScrollBarVisibility="{Binding ElementName=ScrollViewHVisb,Path=SelectedValue}"
VerticalScrollBarVisibility="{Binding ElementName=ScrollViewVVisb,Path=SelectedValue}">
<DockPanel>
<Label Content="WrapPanel" Background="#FFCBCBEA" DockPanel.Dock="Top" />
<WrapPanel ItemWidth="{Binding ElementName=Rect1,Path=Width}"
ItemHeight="{Binding ElementName=Rect1,Path=Height}"
Orientation="{Binding ElementName=CmbOrientation,Path=SelectedValue}">
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容1" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容2" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容3" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容4" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容5" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容6" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<UniformGrid Rows="1" Margin="5,0" MinWidth="200"
u:ElasticWrapPanel.FixToRB="True"
HorizontalAlignment="{Binding ElementName=cmbHorAlig,Path=SelectedValue}"
VerticalAlignment="{Binding ElementName=cmbVerAlig,Path=SelectedValue}">
<Button Content="查询" MinHeight="22" Margin="1" />
<Button Content="导出" MinHeight="22" Margin="1" />
</UniformGrid>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容1" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容2" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容3" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容4" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容5" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容6" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<UniformGrid Rows="1" Margin="5,0" MinWidth="200"
u:ElasticWrapPanel.FixToRB="True"
HorizontalAlignment="{Binding ElementName=cmbHorAlig,Path=SelectedValue}"
VerticalAlignment="{Binding ElementName=cmbVerAlig,Path=SelectedValue}">
<Button Content="查询" MinHeight="22" Margin="1" />
<Button Content="导出" MinHeight="22" Margin="1" />
</UniformGrid>
</WrapPanel>
</DockPanel>
</ScrollViewer>
<ScrollViewer
HorizontalScrollBarVisibility="{Binding ElementName=ScrollViewHVisb,Path=SelectedValue}"
VerticalScrollBarVisibility="{Binding ElementName=ScrollViewVVisb,Path=SelectedValue}">
<DockPanel>
<Label Content="ElasticWrapPanel" Background="#FFB4F1AA" DockPanel.Dock="Top" />
<u:ElasticWrapPanel
IsFillHorizontal="{Binding ElementName=chkFillWidth,Path=IsChecked,Mode=TwoWay}"
IsFillVertical="{Binding ElementName=chkFillHeight,Path=IsChecked,Mode=TwoWay}"
ItemWidth="{Binding ElementName=Rect1,Path=Width}"
ItemHeight="{Binding ElementName=Rect1,Path=Height}"
Orientation="{Binding ElementName=CmbOrientation,Path=SelectedValue}">
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容1" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容2" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容3" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容4" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容5" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容6" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<UniformGrid Rows="1" Margin="5,0" MinWidth="200"
u:ElasticWrapPanel.FixToRB="True"
HorizontalAlignment="{Binding ElementName=cmbHorAlig,Path=SelectedValue}"
VerticalAlignment="{Binding ElementName=cmbVerAlig,Path=SelectedValue}">
<Button Content="查询" MinHeight="22" Margin="1" />
<Button Content="导出" MinHeight="22" Margin="1" />
</UniformGrid>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容1" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容2" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容3" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容4" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容5" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"
Height="{Binding ElementName=Rect2,Path=Height}">
<TextBlock Text="内容6" VerticalAlignment="Center" />
<TextBox MinHeight="23" />
</DockPanel>
<UniformGrid Rows="1" Margin="5,0" MinWidth="200"
u:ElasticWrapPanel.FixToRB="True"
HorizontalAlignment="{Binding ElementName=cmbHorAlig,Path=SelectedValue}"
VerticalAlignment="{Binding ElementName=cmbVerAlig,Path=SelectedValue}">
<Button Content="查询" MinHeight="22" Margin="1" />
<Button Content="导出" MinHeight="22" Margin="1" />
</UniformGrid>
</u:ElasticWrapPanel>
</DockPanel>
</ScrollViewer>
</StackPanel>
</TabItem>
</TabControl>
</DockPanel>
</TabItem>
</TabControl>
</DockPanel>
<Border HorizontalAlignment="Right" VerticalAlignment="Top" IsHitTestVisible="False"
BorderBrush="Blue" Background="#FF56AFFD" Margin="5,5,5,5" BorderThickness="1"
TextElement.FontFamily="微软雅黑" TextElement.FontWeight="Thin" Opacity="0.35"
TextElement.Foreground="White" Padding="4">
<StackPanel>
<TextBlock Text="ElasticWrapPanel控件" />
<TextBlock Text="IsFillHorizontal属性有ItemWidth情况下水平平铺" />
<TextBlock Text="IsFillVertical属性有ItemHeight情况下水平平铺" />
<TextBlock Text="ElasticWrapPanel.FixToRB水平排列元素时则向右对齐换行" />
<TextBlock TextAlignment="Right" Text="垂直排列元素时则向底部对齐换行" />
</StackPanel>
</Border>
</Grid>
</UserControl>

View File

@@ -12,9 +12,9 @@ public class ElasticWrapPanel : WrapPanel
static ElasticWrapPanel()
{
IsFillHorizontalProperty.Changed.AddClassHandler<Control>(OnIsFillPropertyChanged);
IsFillHorizontalProperty.Changed.AddClassHandler<Control>(OnIsFillPropertyChanged);
IsFillVerticalProperty.Changed.AddClassHandler<Control>(OnIsFillPropertyChanged);
AffectsMeasure<ElasticWrapPanel>(IsFillHorizontalProperty, IsFillHorizontalProperty);
AffectsMeasure<ElasticWrapPanel>(IsFillHorizontalProperty, IsFillVerticalProperty);
}
#region AttachedProperty
@@ -95,7 +95,7 @@ public class ElasticWrapPanel : WrapPanel
childFixConstraint = new Size(constraint.Width, itemHeight);
break;
case Orientation.Vertical when itemWidthSet:
childFixConstraint = new Size(itemWidth, itemHeight);
childFixConstraint = new Size(itemWidth, constraint.Height);
break;
}