一个优化奇怪的 WrapPanel

article/2025/10/25 7:05:40

 一个优化奇怪的 WrapPanel

本文经原作者授权以原创方式二次分享,欢迎转载、分享。

一个优化奇怪的 WrapPanel

作者:陈-林-赵-魏

原文链接[1]:https://www.cnblogs.com/wandia/p/17092221.html

  • FixToRB 附加属性,固定到【右边(水平模式)|底边(垂直模式)】,这将会导致换行。

  • IsFillHorizontal 依赖属性 是否充满。

  • DoubleGreaterThan 浮点数比较静态方法。

  • MeasureOverride 测量所需元素空间大小。

  • ArrangeOverride 排列元素。

  • UVSize 内部结构体,用于 Orientation 方向上存值及其比较。

313c7fb7bf47f2f0d4b9d1a6e16b3542.png e756213fd612fd28d99f611060104b60.png

1) WrapPanelEx.cs 代码如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;namespace WrapPanelEx.Controls
{/// <summary>    /// WrapPanel改进后,增加了填充式布局,转载请保留博客地址!/// 来源:https://www.cnblogs.com/wandia/p/17092221.html/// 作者:陈-林-赵-魏/// WrapPanel改进,增加了设置元素宽度高度时候填充式铺满/// 代码改自 Microsoft WrapPanel 源码/// </summary>public class WrapPanelEx : WrapPanel{#region 附加属性,固定到【右边(水平模式)|底边(垂直模式)】,这将会导致换行public static readonly DependencyProperty FixToRBProperty = DependencyProperty.RegisterAttached("FixToRB",typeof(bool),typeof(WrapPanelEx),new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));public static void SetFixToRB(UIElement element, bool value){element.SetValue(FixToRBProperty, value);}public static bool GetIsFixToRB(UIElement element){return (bool)element.GetValue(FixToRBProperty);}#endregion#region 依赖属性 是否充满public bool IsFillHorizontal{get { return (bool)GetValue(IsFillHorizontalProperty); }set { SetValue(IsFillHorizontalProperty, value); }}public static readonly DependencyProperty IsFillHorizontalProperty =DependencyProperty.Register("IsFillHorizontal", typeof(bool), typeof(WrapPanelEx),new UIPropertyMetadata(false, OnIsFill_ProperthChanged));public bool IsFillVertical{get { return (bool)GetValue(IsFillVerticalProperty); }set { SetValue(IsFillVerticalProperty, value); }}public static readonly DependencyProperty IsFillVerticalProperty = DependencyProperty.Register("IsFillVertical", typeof(bool), typeof(WrapPanelEx),new UIPropertyMetadata(false, OnIsFill_ProperthChanged));private static void OnIsFill_ProperthChanged(DependencyObject d, DependencyPropertyChangedEventArgs e){WrapPanelEx fill = d as WrapPanelEx;if (fill != null) fill.InvalidateMeasure();}#endregion#region 浮点数比较静态方法private const double DBL_EPSILON = 2.2204460492503131e-016; /* smallest such that 1.0+DBL_EPSILON != 1.0 *///计算2个浮点数是否接近private static bool DoubleAreClose(double value1, double value2){//in case they are Infinities (then epsilon check does not work)if (value1 == value2){return true;}// This computes (|value1-value2| / (|value1| + |value2| + 10.0)) < DBL_EPSILONdouble eps = (Math.Abs(value1) + Math.Abs(value2) + 10.0) * DBL_EPSILON;double delta = value1 - value2;return -eps < delta && eps > delta;}private static bool DoubleGreaterThan(double value1, double value2){return value1 > value2 && !DoubleAreClose(value1, value2);}#endregion#region 测量所需元素空间大小/// <summary>///     <see cref="FrameworkElement.MeasureOverride" />/// </summary>protected override Size MeasureOverride(Size availbleSize){   //设否元素宽的设置,是否元素高度设置bool isItemWidthSet = !double.IsNaN(this.ItemWidth) && this.ItemWidth > 0;bool isItemHeightSet = !double.IsNaN(this.ItemHeight) && this.ItemHeight > 0;//非FixToRB=True元素使用测量需求空间SizeSize childConstraint = new Size((isItemWidthSet ? this.ItemWidth : availbleSize.Width),(isItemHeightSet ? this.ItemHeight : availbleSize.Height));//FixToRB=True元素使用测量需求空间SizeSize childFixConstraint = new Size(availbleSize.Width, availbleSize.Height);if (Orientation == Orientation.Horizontal && isItemHeightSet){childFixConstraint.Height = this.ItemHeight;}if (Orientation == Orientation.Vertical && isItemWidthSet){childConstraint.Width = this.ItemWidth;}//这个给非空间测量大小UVSize ItemSetSize = new UVSize(this.Orientation,(isItemWidthSet ? this.ItemWidth : 0),(isItemHeightSet ? this.ItemHeight : 0));//给定的空间大小测量UvSize,用于没有ItemWidth和ItemHeight时候测量元素空间大小, FixToRB=True的元素也使用这个UVSize uvConstraint = new UVSize(Orientation, availbleSize.Width, availbleSize.Height);UVSize curLineSize = new UVSize(Orientation);           //将元素按照水平/垂直排列的方式得出同一行/列所需的空间需求UVSize desireResultSize = new UVSize(Orientation);      //计算处此WrapPanelEx所需的空间大小需求结果UIElementCollection children = InternalChildren;        //拿到内部元素,用于遍历for (int i = 0, count = children.Count; i < count; i++){UIElement child = children[i];          //此元素/当前元素if (child == null) continue;UVSize sz = new UVSize();if (WrapPanelEx.GetIsFixToRB(child) == true){   //此元素需要设置到固定靠右/底的型为操作,测量元素大小时需要放开child.Measure(childFixConstraint);sz = new UVSize(Orientation, child.DesiredSize.Width, child.DesiredSize.Height);//主要是我对与这个固定住的元素的需求宽度高度按照那个标准有点头疼,干脆放开用最大控件算了if (sz.U > 0 && ItemSetSize.U > 0){if (sz.U < ItemSetSize.U){   //保持比例sz.U = ItemSetSize.U;}else{   //设置了同方向中元素的长度,所以这里要按照比例//double lengthCount = Math.Ceiling(sz.U / ItemSetSize.U);//sz.U = lengthCount * ItemSetSize.U;sz.U = Math.Min(sz.U, uvConstraint.U);//这里防止意外}}if (sz.V > 0 && ItemSetSize.V > 0 && sz.V < ItemSetSize.V){   //设置了崔志方向元素长度,如果此元素空间需求小于,则按照ItemSetSize.Vsz.V = ItemSetSize.V;}if (DoubleGreaterThan(curLineSize.U + sz.U, uvConstraint.U)){   //当前同一 列/行 如果容纳 此元素空间将超出desireResultSize.U = Math.Max(curLineSize.U, desireResultSize.U);   //取Orientation方向最大长度desireResultSize.V += curLineSize.V;                                //累加垂直Orientation方向的长度curLineSize = sz;//当前元素需要启1个新行desireResultSize.U = Math.Max(curLineSize.U, desireResultSize.U);   //取Orientation方向最大长度desireResultSize.V += curLineSize.V;                                //累加垂直Orientation方向的长度}else{   //这里是元素空间足够 填充式布局curLineSize.U += sz.U;curLineSize.V = Math.Max(sz.V, curLineSize.V);desireResultSize.U = Math.Max(curLineSize.U, desireResultSize.U);   //取Orientation方向最大长度desireResultSize.V += curLineSize.V;                                //累加垂直Orientation方向的长度}//下一个可能是换行元素....curLineSize = new UVSize(Orientation);                                  //用于存放全新1行}else{child.Measure(childConstraint); //如果设置元素宽度或高度, 其高度宽度尽可能按照设置值给定sz = new UVSize(Orientation,(isItemWidthSet ? this.ItemWidth : child.DesiredSize.Width),(isItemHeightSet ? this.ItemHeight : child.DesiredSize.Height));if (DoubleGreaterThan(curLineSize.U + sz.U, uvConstraint.U)){    //当前同一 列/行 如果容纳 此元素空间将超出desireResultSize.U = Math.Max(curLineSize.U, desireResultSize.U); //取Orientation方向最大长度desireResultSize.V += curLineSize.V;                              //累加垂直Orientation方向的长度curLineSize = sz;                                   //当前行宽度if (DoubleGreaterThan(sz.U, uvConstraint.U)){   //此元素同Orientation方向长度大于给定约束长度,则当前元素为一行desireResultSize.U = Math.Max(sz.U, desireResultSize.U);desireResultSize.V += sz.V;curLineSize = new UVSize(Orientation);  //用于存放全新1行狂赌}}else{   //当前同一 列/行 元素空间足够,可以容纳当前元素curLineSize.U += sz.U;curLineSize.V = Math.Max(sz.V, curLineSize.V);}}}//the last line size, if any should be added  因为超出才累计,最后1行不超出,需要重新添加desireResultSize.U = Math.Max(curLineSize.U, desireResultSize.U);desireResultSize.V += curLineSize.V;//go from UV space to W/H space               将UV值转换成 高度/宽度值return new Size(desireResultSize.Width, desireResultSize.Height);}#endregion#region 排列元素/*var count = Math.Floor(constraint.Width / this.ItemWidth);  //元素个数var averageWidth = constraint.Width / Math.Max(count, 1);   //平均宽度childConstraint.Width = Math.Max(averageWidth, this.ItemWidth);*//// <summary>///     <see cref="FrameworkElement.ArrangeOverride" />/// </summary>protected override Size ArrangeOverride(Size finalSize){//设否元素宽的设置,是否元素高度设置bool isItemWidthSet = !double.IsNaN(this.ItemWidth) && this.ItemWidth > 0;bool isItemHeightSet = !double.IsNaN(this.ItemHeight) && this.ItemHeight > 0;//这个给非空间测量大小UVSize ItemSetSize = new UVSize(this.Orientation,(isItemWidthSet ? this.ItemWidth : 0),(isItemHeightSet ? this.ItemHeight : 0));//给定的空间大小测量UvSize,用于没有ItemWidth和ItemHeight时候测量元素空间大小, FixToRB=True的元素也使用这个UVSize uvConstraint = new UVSize(Orientation, finalSize.Width, finalSize.Height);//用于存放同一方向的元素列/行 集合List<UVCollection> lineUiCollection = new List<UVCollection>();#region 得到同一方向元素集合的集合//if (lineUiCollection != null)   //写一个If只是用于减少外层变量,反感的请将if注释{//当前元素集合行/列UVCollection curLineUis = new UVCollection(this.Orientation, ItemSetSize);//遍历内部元素UIElementCollection children = InternalChildren;        //拿到内部元素,用于遍历for (int i = 0, count = children.Count; i < count; i++){UIElement child = children[i];               //此元素/当前元素if (child == null || child.Visibility == Visibility.Collapsed) continue;UVSize sz = new UVSize();if (WrapPanelEx.GetIsFixToRB(child) == true){   //此元素需要设置到固定靠右/底的型为操作,测量元素大小时需要放开sz = new UVSize(Orientation, child.DesiredSize.Width, child.DesiredSize.Height);double lengthCount = 1;if (sz.U > 0 && ItemSetSize.U > 0){if (sz.U < ItemSetSize.U){   //保持比例sz.U = ItemSetSize.U;}else{   //设置了同方向中元素的长度,所以这里要按照比例lengthCount = Math.Ceiling(sz.U / ItemSetSize.U);//sz.U = lengthCount * ItemSetSize.U;sz.U = Math.Min(sz.U, uvConstraint.U);}}if (sz.V > 0 && ItemSetSize.V > 0 && sz.V < ItemSetSize.V){   //设置了崔志方向元素长度,如果此元素空间需求小于,则按照ItemSetSize.Vsz.V = ItemSetSize.V;}if (DoubleGreaterThan(curLineUis.TotalU + sz.U, uvConstraint.U)){   //当前同一 列/行 如果容纳 此元素空间将超出if (curLineUis.Count > 0){lineUiCollection.Add(curLineUis);}curLineUis = new UVCollection(Orientation, ItemSetSize);curLineUis.Add(child, sz, Convert.ToInt32(lengthCount));}else{   //这里是元素空间足够curLineUis.Add(child, sz, Convert.ToInt32(lengthCount));}lineUiCollection.Add(curLineUis);//下一个可能是换行元素....不管了以后闲得蛋疼再弄吧curLineUis = new UVCollection(Orientation, ItemSetSize);}else{sz = new UVSize(Orientation,(isItemWidthSet ? this.ItemWidth : child.DesiredSize.Width),(isItemHeightSet ? this.ItemHeight : child.DesiredSize.Height));if (DoubleGreaterThan(curLineUis.TotalU + sz.U, uvConstraint.U)){    //当前同一 列/行 如果容纳 此元素空间将超出if (curLineUis.Count > 0){lineUiCollection.Add(curLineUis);}curLineUis = new UVCollection(Orientation, ItemSetSize);curLineUis.Add(child, sz);if (DoubleGreaterThan(sz.U, uvConstraint.U)){lineUiCollection.Add(curLineUis);curLineUis = new UVCollection(Orientation, ItemSetSize);}}else{   //空间足够curLineUis.Add(child, sz);}}}if (curLineUis.Count > 0 && !lineUiCollection.Contains(curLineUis)){lineUiCollection.Add(curLineUis);}}#endregionbool isFillU = false;bool isFillV = false;switch (this.Orientation){case Orientation.Horizontal:isFillU = this.IsFillHorizontal;isFillV = this.IsFillVertical;break;case Orientation.Vertical:isFillU = this.IsFillVertical;isFillV = this.IsFillHorizontal;break;}if (lineUiCollection.Count > 0){double accumulatedV = 0;double adaptULength = 0;bool isAdaptV = false;double adaptVLength = 0;if (isFillU == true){if (ItemSetSize.U > 0){int maxElementCount = lineUiCollection.Max(uiSet => uiSet.UiCollection.Sum(p => p.Value.ULengthCount));adaptULength = (uvConstraint.U - maxElementCount * ItemSetSize.U) / maxElementCount;adaptULength = Math.Max(adaptULength, 0);}}if (isFillV == true){if (ItemSetSize.V > 0){isAdaptV = true;adaptVLength = uvConstraint.V / lineUiCollection.Count;}}bool isHorizontal = (Orientation == Orientation.Horizontal);foreach (UVCollection lineUvCollection in lineUiCollection){double u = 0;List<UIElement> lineUiEles = lineUvCollection.UiCollection.Keys.ToList();double linevV = isAdaptV ? adaptVLength : lineUvCollection.LineV;for (int i = 0; i < lineUiEles.Count; i++){UIElement child = lineUiEles[i];UVLengthSize childSize = lineUvCollection.UiCollection[child];double layoutSlotU = childSize.UVSize.U + childSize.ULengthCount * adaptULength;double layoutSlotV = isAdaptV ? linevV : childSize.UVSize.V;if (WrapPanelEx.GetIsFixToRB(child) == false){child.Arrange(new Rect((isHorizontal ? u : accumulatedV),(isHorizontal ? accumulatedV : u),(isHorizontal ? layoutSlotU : layoutSlotV),(isHorizontal ? layoutSlotV : layoutSlotU)));}else{if (ItemSetSize.U > 0){   //说明同方向有宽度设置,这里尽量按照ItemULength保持layoutSlotU = childSize.ULengthCount * ItemSetSize.U + childSize.ULengthCount * adaptULength;double leaveULength = uvConstraint.U - u;layoutSlotU = Math.Min(leaveULength, layoutSlotU);}child.Arrange(new Rect((isHorizontal ? Math.Max(0, (uvConstraint.U - layoutSlotU)) : accumulatedV),(isHorizontal ? accumulatedV : Math.Max(0, (uvConstraint.U - layoutSlotU))),(isHorizontal ? layoutSlotU : layoutSlotV),(isHorizontal ? layoutSlotV : layoutSlotU)));}u += layoutSlotU;}accumulatedV += linevV;lineUiEles.Clear();}}lineUiCollection.ForEach(col => col.Dispose());lineUiCollection.Clear();return finalSize;}#endregion#region 内部结构体,用于 Orientation 方向上存值及其比较 private struct UVSize{internal UVSize(Orientation orientation, double width, double height){U = V = 0d;_orientation = orientation;Width = width;Height = height;}internal UVSize(Orientation orientation){U = V = 0d;_orientation = orientation;}internal double U;      //同一排序方向上的值internal double V;      //垂直方向上的值private Orientation _orientation;internal double Width{get { return (_orientation == Orientation.Horizontal ? U : V); }set { if (_orientation == Orientation.Horizontal) U = value; else V = value; }}internal double Height{get { return (_orientation == Orientation.Horizontal ? V : U); }set { if (_orientation == Orientation.Horizontal) V = value; else U = value; }}}private class UVLengthSize{public UVSize UVSize { get; set; }public int ULengthCount { get; set; }public UVLengthSize(UVSize uvSize, int uLengthCount){this.UVSize = uvSize;this.ULengthCount = uLengthCount;}}/// <summary>/// 用于存放同一行/列的元素/// </summary>private class UVCollection : IDisposable{public Dictionary<UIElement, UVLengthSize> UiCollection { get; private set; }private UVSize LineDesireUvSize;private UVSize ItemSetSize;public UVCollection(Orientation orientation, UVSize ItemSetSize){this.UiCollection = new Dictionary<UIElement, UVLengthSize>();LineDesireUvSize = new UVSize(orientation);this.ItemSetSize = ItemSetSize;}public double TotalU{get{return LineDesireUvSize.U;}}//垂直方向长度public double LineV{get{return LineDesireUvSize.V;}}public void Add(UIElement element, UVSize childSize, int itemULength = 1){if (this.UiCollection.ContainsKey(element))throw new InvalidOperationException("元素已存在,不可重复添加");this.UiCollection[element] = new UVLengthSize(childSize, itemULength);LineDesireUvSize.U += childSize.U;LineDesireUvSize.V = Math.Max(LineDesireUvSize.V, childSize.V);}public int Count{get{return this.UiCollection.Count;}}public void Dispose(){if (this.UiCollection != null){this.UiCollection.Clear();}this.UiCollection = null;}}#endregion}
}

2) MainWindow.xaml 代码如下:

<wd:Window x:Class="WrapPanelEx.Demo.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers"xmlns:local="clr-namespace:WrapPanelEx.Demo"xmlns:Controls="clr-namespace:WrapPanelEx.Controls"mc:Ignorable="d"Title="陈-林-赵-魏 WrapPanelEx" Height="350" Width="525"><Window.Resources><Style TargetType="TextBlock"><Setter Property="Foreground" Value="Black"/></Style></Window.Resources><Grid Margin="4"><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="Auto" Visibility="Collapsed"/><TextBox x:Name="txtItemWidth" MinWidth="60" VerticalContentAlignment="Center"Text="{Binding ElementName=Rect1,Path=Width,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/></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" VerticalContentAlignment="Center"Text="{Binding ElementName=Rect1,Path=Height,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/></Grid><TextBlock Text="* 数字可填入NaN" Foreground="Red" VerticalAlignment="Center"/></StackPanel><TabControl><TabItem Header="平铺Demo"><TabControl><TabItem Header="情景1(高度充满)"><Controls:WrapPanelEx x:Name="WrapPanelFill"  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></Controls:WrapPanelEx></TabItem><TabItem Header="情景2(高度Auto)"><Grid><Grid.RowDefinitions><RowDefinition Height="auto"/><RowDefinition/></Grid.RowDefinitions><Controls:WrapPanelEx 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></Controls:WrapPanelEx><Border Grid.Row="1" BorderThickness="1" BorderBrush="Red" Margin="0,4" Visibility="Visible"><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}"><Controls:WrapPanelEx x:Name="WrapPanelFill3" 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></Controls:WrapPanelEx></ScrollViewer></Border></TabItem></TabControl></TabItem><TabItem Header="平铺+靠右"><DockPanel><StackPanel  DockPanel.Dock="Top" Orientation="Horizontal"><TextBlock Text="输入控件宽度" VerticalAlignment="Center"/><Grid><Rectangle x:Name="Rect2" Visibility="Collapsed"/><TextBox MinWidth="60"  VerticalContentAlignment="Center"Text="{Binding ElementName=Rect2,Path=Width,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/></Grid><TextBlock Text="输入控件高度" VerticalAlignment="Center"/><Grid><TextBox MinWidth="60" VerticalContentAlignment="Center"Text="{Binding ElementName=Rect2,Path=Height,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/></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="一个"><UniformGrid x:Name="UnifornGrid1" Rows="1" ><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 /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容2" VerticalAlignment="Center"/><TextBox /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容3" VerticalAlignment="Center"/><TextBox /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容4" VerticalAlignment="Center"/><TextBox  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容5" VerticalAlignment="Center"/><TextBox  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容6" VerticalAlignment="Center"/><TextBox  /></DockPanel><UniformGrid  Rows="1" Margin="5,0"  MinWidth="200"Controls:WrapPanelEx.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="WrapPanelFill" Background="#FFB4F1AA" DockPanel.Dock="Top" /><Controls:WrapPanelEx 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  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容2" VerticalAlignment="Center"/><TextBox  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容3" VerticalAlignment="Center"/><TextBox  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容4" VerticalAlignment="Center"/><TextBox  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容5" VerticalAlignment="Center"/><TextBox  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容6" VerticalAlignment="Center"/><TextBox  /></DockPanel><UniformGrid  Rows="1" Margin="5,0"  MinWidth="200"Controls:WrapPanelEx.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></Controls:WrapPanelEx></DockPanel></ScrollViewer></UniformGrid></TabItem><TabItem Header="多个"><UniformGrid x:Name="UnifornGrid2" Rows="1" ><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  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容2" VerticalAlignment="Center"/><TextBox  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容3" VerticalAlignment="Center"/><TextBox  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容4" VerticalAlignment="Center"/><TextBox  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容5" VerticalAlignment="Center"/><TextBox  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容6" VerticalAlignment="Center"/><TextBox  /></DockPanel><UniformGrid  Rows="1" Margin="5,0"  MinWidth="200"Controls:WrapPanelEx.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  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容2" VerticalAlignment="Center"/><TextBox  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容3" VerticalAlignment="Center"/><TextBox  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容4" VerticalAlignment="Center"/><TextBox  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容5" VerticalAlignment="Center"/><TextBox  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容6" VerticalAlignment="Center"/><TextBox  /></DockPanel><UniformGrid  Rows="1" Margin="5,0"  MinWidth="200"Controls:WrapPanelEx.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="WrapPanelFill" Background="#FFB4F1AA" DockPanel.Dock="Top" /><Controls:WrapPanelEx 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  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容2" VerticalAlignment="Center"/><TextBox  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容3" VerticalAlignment="Center"/><TextBox  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容4" VerticalAlignment="Center"/><TextBox  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容5" VerticalAlignment="Center"/><TextBox  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容6" VerticalAlignment="Center"/><TextBox  /></DockPanel><UniformGrid  Rows="1" Margin="5,0"  MinWidth="200"Controls:WrapPanelEx.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  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容2" VerticalAlignment="Center"/><TextBox  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容3" VerticalAlignment="Center"/><TextBox  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容4" VerticalAlignment="Center"/><TextBox  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容5" VerticalAlignment="Center"/><TextBox  /></DockPanel><DockPanel Margin="0,2" Width="{Binding ElementName=Rect2,Path=Width}"Height="{Binding ElementName=Rect2,Path=Height}"><TextBlock Text="内容6" VerticalAlignment="Center"/><TextBox  /></DockPanel><UniformGrid  Rows="1" Margin="5,0"  MinWidth="200"Controls:WrapPanelEx.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></Controls:WrapPanelEx></DockPanel></ScrollViewer></UniformGrid></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="WrapPanelEx控件"/><TextBlock Text="IsFillHorizontal属性:有ItemWidth情况下水平平铺"/><TextBlock Text="IsFillVertical属性:有ItemHeight情况下水平平铺"/><TextBlock Text="WrapPanelEx.FixToRB:水平排列元素时则向右对齐换行"/><TextBlock TextAlignment="Right" Text="垂直排列元素时则向底部对齐换行" /></StackPanel></Border></Grid>
</wd:Window>
ee33d63b876509b4030a07d8bac6f2a6.gif

参考资料

[1]

原文链接: https://www.cnblogs.com/wandia/p/17092221.html


http://chatgpt.dhexx.cn/article/7kF2R2bR.shtml

相关文章

WPF布局之WrapPanel与StackPanel

转载&#xff1a;https://www.cnblogs.com/Im-Victor/p/10565030.html 三. WrapPanel WrapPanel布局面板将各个控件从左至右按照行或列的顺序罗列&#xff0c;当长度或高度不够是就会自动调整进行换行&#xff0c;后续排序按照从上至下或从右至左的顺序进行。 Orientation——…

WrapPanel在不同页面渲染使用

WrapPanel渲染的使用 WrapPanel在UserControl用户控件的使用 页面控件的是渲染出来&#xff0c;在UserControl用户控件的使用无法直接使用&#xff0c;使用会出现空&#xff0c;没法渲染获取到WrapPanel控件。 没法渲染获取效果图&#xff1a; 想成功获取渲染获取到WrapPane…

WPF 入门教程WrapPanel介绍

WrapPanel将定位每个子控件的旁边&#xff0c;另外&#xff0c;水平方向&#xff08;默认值&#xff09;或垂直&#xff0c;直到没有更多的空间&#xff0c;在那里将换到下一行&#xff0c;然后继续。当您想要一个垂直或水平列表控件在没有更多空间时自动换行时使用它。 当 Wr…

WPF WrapPanel、UniformGrid、DockPanel介绍

WPF WrapPanel、UniformGrid、DockPanel介绍 WrapPanel WrapPanel , 具有在有限的容器范围内, 可以自动换行, 或者换列处理。具体则取决于WrapPanel的排列方式 (Orientation)。 Orientation"Horizontal"时各控件从左至右罗列&#xff0c;当面板长度不够时&#xff…

WPF控件之WrapPanel的用法

简单来说&#xff0c;WrapPanel就是一个可以行填充&#xff0c;自动换行。或者列填充&#xff0c;自动换列的一个布局容器。 如下所示&#xff0c;它会自动将10个button分成2行 <WrapPanel><Button Content"button1" /><Button Content"button…

WrapPanel:自动折行面板(环绕面板)基础简述

WrapPanel布局面板将各个控件从左至右按照行或列的顺序罗列&#xff0c;当长度或高度不够时就会自动调整进行换行或换列&#xff0c;后续排序按照从上至下或从右至左的顺序进行。 Orientation——根据内容自动换行。当Orientation属性的值设置为 Horizontal&#xff1a;元素是…

WPF 控件专题 WrapPanel 控件详解

1、WrapPanel 介绍 官方释义&#xff1a;WrapPanel&#xff08;环绕面板&#xff09;&#xff1a;按从左到右的顺序位置定位子元素&#xff0c;在包含框的边缘处将内容切换到下一行。 后续排序按照从上至下或从右至左的顺序进行&#xff0c;具体取决于 Orientation 属性的值。 …

UI Automation编程辅助工具Inspect的下载和使用

UIAutomation微软提供的UI自动化库&#xff0c;主要用AutomationElement类来表示UI 自动化目录树中的一个UI自动化元素&#xff0c;.NET Windows的窗体应用程序和WPF应用程序。 Inspect是一款类似于SPY的界面捕捉工具。外观如下&#xff1a; 下载地址&#xff1a; Inspect.zip …

docker inspect --format 详解

docker inspect --format 文章目录 docker inspect --format1. 什么是模板2. Go模板语法3. 变量3.1 系统变量 {{.}}3.2 自定义变量3.3 遍历&#xff08;循环&#xff09;&#xff1a;range 4. index5. 判断5.1 not5.2 or5.3 判断条件5.4 判断示例 6. 打印信息9. 管道10. 内置函…

android studio inspect code,Android Studio使用inspect code删除 unused import

项目经常需要从别的项目复制一些文件过来&#xff0c;但是经常出现大片的导包unused import&#xff0c;但是我用自动导包并没有效果&#xff0c;必须把这些错误的导包手动删除才可以导入正确的包&#xff0c;虽然文件不多&#xff0c;手动删除是可以完成的&#xff0c;但是作为…

Halcon Variable Inspect 安装失败

这里写自定义目录标题 Halcon Variable Inspect 安装失败 Halcon Variable Inspect 安装失败 在 Visual Studio 2022 环境下安装 HALCON2105ProgressVariableInspect.vsix 失败。 点击 “View Install Log” 查看日志。 主要问题在运行vsix文件时&#xff0c;它会监控然后运行…

docker inspect 查看部分数据

1. 问题描述 使用docker inspect命令可查看 docker 镜像/容器/数据卷 等的具体配置docker inspect命令格式docker inspect [参数] 容器名/容器ID/镜像名/镜像ID/数据卷名...如果不加参数&#xff0c;则输出很多&#xff0c;难以精确查看真正关心的内容 如果使用grep 表达式&am…

【网络教程】如何安装inspect.exe

文章目录 安装 安装 Inspect&#xff08;Inspect.exe&#xff09;是一个基于Windows的工具&#xff0c;允许您选择任何UI元素并查看元素的可访问性数据。您可以查看Microsoft UI自动化属性和控制模式&#xff0c;以及Microsoft活动辅助功能属性。Inspect还允许您测试UI自动化树…

inspect.exe安装使用

官网下载 https://developer.microsoft.com/zh-cn/windows/downloads/windows-sdk/ 官网教程 https://learn.microsoft.com/zh-cn/windows/win32/winauto/inspect-objects 要求 系统要求 Windows SDK 具有以下最低系统要求&#xff1a; 支持的操作系统 Windows 10版本 150…

python中inspect模块用法详解

获取函数签名对象。函数签名包含了一个函数的信息&#xff0c;包括函数名、它的参数类型、它所在的类和名称空间及其他信息&#xff09;。 inspect模块主要提供了四种用处&#xff1a; 对是否是模块、框架、函数进行类型检查获取源码获取类或者函数的参数信息解析堆栈 1、对…

docker inspect

docker inspect 命令用于获取有关 Docker 容器、镜像、网络等的详细信息。它提供了关于指定对象的元数据和配置的完整视图&#xff0c;包括运行状态、网络设置、卷挂载、环境变量等。 以下是一些常见的字段和属性&#xff0c;可以根据需要选择其中一些或全部列出&#xff1a; …

UI自动化辅助工具Inspect

了解更多访问&#xff1a;windows应用程序GUI自动化控制 Inspect&#xff08;Inspect.exe&#xff09;是一个基于Windows的工具&#xff0c;允许您选择任何UI元素并查看元素的可访问性数据。您可以查看Microsoft UI自动化属性和控制模式&#xff0c;以及Microsoft活动辅助功能…

mysql数据库基础管理--数据库权限表

mysql数据库通过权限表实现对mysql数据库的访问&#xff0c;权限表存放在mysql数据库中&#xff0c;有脚本 mysql_install_db初始化。 存储账户权限表主要 USER,DB,HOST,TABLES_PRIV,COLUMNS_PRIV和PROCS_PRIV. mysql.USER 记录允许连接到数据库的用户信息&#xff0c;里面…

1、user权限表详解

MySQL 在安装时会自动创建一个名为 mysql 的数据库&#xff0c;mysql 数据库中存储的都是用户权限表。用户登录以后&#xff0c;MySQL 会根据这些权限表的内容为每个用户赋予相应的权限。 user 表是 MySQL 中最重要的一个权限表&#xff0c;用来记录允许连接到服务器的账号信息…

MySQL中用户权限、库权限、表权限的控制

MySQL中用户权限、库权限、表权限的控制 在开发中&#xff0c;除了可以在脚本代码中控制开发者对MySQL数据库数据表的权限&#xff0c;还可以在mysql层面进行控制。 对mysql的权限的控制可以大致分为三个层面&#xff1a;①连接上允不允许&#xff08;是否能登录到mysql服务器…