Gets or sets a value that identifies a ColumnDefinition or RowDefinition as a member of a defined group that shares sizing properties. This is a dependency property.
Namespace:
System.Windows.Controls
Assembly:
PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
Visual Basic (Declaration)
Public Property SharedSizeGroup As String
Dim instance As DefinitionBase
Dim value As String
value = instance.SharedSizeGroup
instance.SharedSizeGroup = value
public string SharedSizeGroup { get; set; }
public:
property String^ SharedSizeGroup {
String^ get ();
void set (String^ value);
}
public function get SharedSizeGroup () : String
public function set SharedSizeGroup (value : String)
<object SharedSizeGroup="string" .../>
Dependency Property Information
Columns and rows that participate in size-sharing do not respect Star sizing. In the size-sharing scenario, Star sizing is treated as Auto.
Grid size-sharing does not work if you set IsSharedSizeScope to true within a resource template and you define SharedSizeGroup as outside that template.
The SharedSizeGroup property value must satisfy the following rules:
Must not be empty.
Must only consist of letters, digits, and underscore characters.
Must not start with a numeric value.
This example shows how to share the sizing data of columns and rows between Grid elements in order to keep sizing consistent.
The following example introduces two Grid elements as child elements of a parent DockPanel. The IsSharedSizeScope attached property of Grid is defined on the parent DockPanel.
The example manipulates the property value by using two Button elements; each element represents one of the Boolean property values. When the IsSharedSizeScope property value is set to true, each column or row member of a SharedSizeGroup shares sizing information, regardless of the content of a row or column.
<DockPanel Name="dp1" Grid.IsSharedSizeScope="False" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10">
...
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
<Button Click="setTrue" Margin="0,0,10,10">Set IsSharedSizeScope="True"</Button>
<Button Click="setFalse" Margin="0,0,10,10">Set IsSharedSizeScope="False"</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
<Grid ShowGridLines="True" Margin="0,0,10,0">
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="FirstColumn"/>
<ColumnDefinition SharedSizeGroup="SecondColumn"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" SharedSizeGroup="FirstRow"/>
</Grid.RowDefinitions>
<Rectangle Fill="Silver" Grid.Column="0" Grid.Row="0" Width="200" Height="100"/>
<Rectangle Fill="Blue" Grid.Column="1" Grid.Row="0" Width="150" Height="100"/>
<TextBlock Grid.Column="0" Grid.Row="0" FontWeight="Bold">First Column</TextBlock>
<TextBlock Grid.Column="1" Grid.Row="0" FontWeight="Bold">Second Column</TextBlock>
</Grid>
<Grid ShowGridLines="True">
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="FirstColumn"/>
<ColumnDefinition SharedSizeGroup="SecondColumn"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" SharedSizeGroup="FirstRow"/>
</Grid.RowDefinitions>
<Rectangle Fill="Silver" Grid.Column="0" Grid.Row="0"/>
<Rectangle Fill="Blue" Grid.Column="1" Grid.Row="0"/>
<TextBlock Grid.Column="0" Grid.Row="0" FontWeight="Bold">First Column</TextBlock>
<TextBlock Grid.Column="1" Grid.Row="0" FontWeight="Bold">Second Column</TextBlock>
</Grid>
</StackPanel>
<TextBlock Margin="10" DockPanel.Dock="Top" Name="txt1"/>
The following code-behind example handles the methods that the button Click event raises. The example writes the results of these method calls to TextBlock elements that use related get methods to output the new property values as strings.
Private Sub setTrue(ByVal sender As Object, ByVal args As RoutedEventArgs)
Grid.SetIsSharedSizeScope(dp1, True)
txt1.Text = "IsSharedSizeScope Property is set to " + Grid.GetIsSharedSizeScope(dp1).ToString()
End Sub
Private Sub setFalse(ByVal sender As Object, ByVal args As RoutedEventArgs)
Grid.SetIsSharedSizeScope(dp1, False)
txt1.Text = "IsSharedSizeScope Property is set to " + Grid.GetIsSharedSizeScope(dp1).ToString()
End Sub
private void setTrue(object sender, System.Windows.RoutedEventArgs e)
{
Grid.SetIsSharedSizeScope(dp1, true);
txt1.Text = "IsSharedSizeScope Property is set to " + Grid.GetIsSharedSizeScope(dp1).ToString();
}
private void setFalse(object sender, System.Windows.RoutedEventArgs e)
{
Grid.SetIsSharedSizeScope(dp1, false);
txt1.Text = "IsSharedSizeScope Property is set to " + Grid.GetIsSharedSizeScope(dp1).ToString();
}
For the complete sample, see Grid Size Sharing Sample.
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
.NET Framework
Supported in: 3.5, 3.0
Reference