第一个 Grid 里面的首列放入一个按钮,按钮点击的时候修改按钮的宽度,代码如下 <Grid local:ColumnSharedSizeHelper.IsSharedSizeScope="true ="S1" Click="Button_OnClick"/> </Grid> </Grid> 如以上代码可以看到添加了名为 ColumnSharedSizeHelper 的辅助类用来提供 IsSharedSizeScope readonly DependencyProperty IsSharedSizeScopeProperty = DependencyProperty.RegisterAttached("IsSharedSizeScope
Grid.IsSharedSizeScope:指示是否应在网格中共享相同大小的列或行。 Grid.IsSharedSizeScope:表示是否启用共享大小。VerticalAlignment:竖直对齐方式。HorizontalAlignment:水平对齐方式。
<RowDefinition Height="24*" /> </Grid.RowDefinitions> <ListBox Grid.IsSharedSizeScope
在这里我参考 Grid.IsSharedSizeScope 附加属性 自定义了一个 IsValidationScope 属性作为标识: public static bool GetIsValidationScope
<StackPanel Grid.IsSharedSizeScope="True"> <kino:FormItem Label="用户名" IsRequired="True"> 应用了SharedSizeGroup属性的元素会找到IsSharedSizeScope设置true的父元素(也就是Form),然后同步这个父元素中所有SharedSizeGroup值相同的对应列。