Grid.IsSharedSizeScope Grid.IsSharedSizeScope Grid.IsSharedSizeScope Attached Property

Definition

Dient zum Abrufen oder Festlegen eines Werts, der angibt, dass mehrere Grid-Elemente die Größeninformationen gemeinsam nutzen.Gets or sets a value that indicates that multiple Grid elements are sharing size information.

see GetIsSharedSizeScope, and SetIsSharedSizeScope
see GetIsSharedSizeScope, and SetIsSharedSizeScope
see GetIsSharedSizeScope, and SetIsSharedSizeScope

Beispiele

Die folgenden Codebeispielen wird veranschaulicht, wie Sie mit der IsSharedSizeScope -Eigenschaft in Extensible Application Markup Language (XAML)Extensible Application Markup Language (XAML) und Code.The following code examples demonstrate how to use the IsSharedSizeScope property in Extensible Application Markup Language (XAML)Extensible Application Markup Language (XAML) and code.

<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"/>

......

Ereignisse, die in definierten Extensible Application Markup Language (XAML)Extensible Application Markup Language (XAML) mithilfe von Code behandelt werden.Events defined in Extensible Application Markup Language (XAML)Extensible Application Markup Language (XAML) are handled using code.

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();
}
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

Hinweise

Spalten und Zeilen, die Teilnahme an größenverteilung nicht berücksichtigt Star größenanpassung.Columns and rows participating in size sharing do not respect Star sizing. In diesem Szenario Star größenanpassung behandelt, als Auto.In this scenario, Star sizing is treated as Auto.

Rastergröße funktionieren nicht, wenn IsSharedSizeScope nastaven NA hodnotu true innerhalb der Ressourcenvorlage eine, und ein SharedSizeGroup außerhalb dieser Vorlage definiert ist.Grid size sharing does not work if IsSharedSizeScope is set to true within a resource template, and a SharedSizeGroup is defined outside of that template.

Informationen zur AbhängigkeitseigenschaftDependency Property Information

Feld "ID"Identifier field IsSharedSizeScopeProperty
Legen Sie auf der Metadaten-Eigenschaften trueMetadata properties set to true NoneNone

Gilt für: