SharedSizeGroup for Silverlight
本文关键字:Silverlight for SharedSizeGroup | 更新日期: 2023-09-27 18:11:23
在Wpf中,我们有SharedSizeGroup属性来共享网格之间的列大小。有人知道Silverlight中有类似的功能支持吗?
共享大小在Silverlight中最好使用元素属性绑定实现。只要让所有共享大小的元素绑定到另一个元素的宽度/高度。
参考:
<UserControl x:Class="SLTestApp.MainPage"
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:ext="clr-namespace:System.Windows.Controls.Extensions;assembly=System.Windows.Controls.Extensions"
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
<Grid x:Name="LayoutRoot" Background="White" ext:SharedSize.IsSharedSizeScope="True">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid x:Name="firstfirstGrid" Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" ext:SharedSize.SharedSizeGroup="A"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" ext:SharedSize.SharedSizeGroup="A"/>
</Grid.ColumnDefinitions>
<Border BorderBrush="Green" BorderThickness="2">
<TextBlock x:Name="txtFirstFirst" >
<Run>aa</Run>
<LineBreak />
<Run>aa</Run>
</TextBlock>
</Border>
</Grid>
<Grid x:Name="firstsecondGrid" Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" ext:SharedSize.SharedSizeGroup="A"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" ext:SharedSize.SharedSizeGroup="A"/>
</Grid.ColumnDefinitions>
<Border BorderBrush="Blue" BorderThickness="2">
<TextBlock Text="aaaaaaaaaaaaaaaa" />
</Border>
</Grid>
</Grid>
</UserControl>
参考链接:
http://die-rooter.de/ITworks/archives/27-SharedSize-Grid-with-Silverlight.html<UserControl x:Class="SLTestApp.MainPage"
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:ext="clr-namespace:System.Windows.Controls.Extensions;assembly=System.Windows.Controls.Extensions"
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
<Grid x:Name="LayoutRoot" Background="White" ext:SharedSize.IsSharedSizeScope="True">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid x:Name="firstfirstGrid" Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" ext:SharedSize.SharedSizeGroup="A"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" ext:SharedSize.SharedSizeGroup="A"/>
</Grid.ColumnDefinitions>
<Border BorderBrush="Green" BorderThickness="2">
<TextBlock x:Name="txtFirstFirst" >
<Run>aa</Run>
<LineBreak />
<Run>aa</Run>
</TextBlock>
</Border>
</Grid>
<Grid x:Name="firstsecondGrid" Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" ext:SharedSize.SharedSizeGroup="A"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" ext:SharedSize.SharedSizeGroup="A"/>
</Grid.ColumnDefinitions>
<Border BorderBrush="Blue" BorderThickness="2">
<TextBlock Text="aaaaaaaaaaaaaaaa" />
</Border>
</Grid>
</Grid>
</UserControl>