Reputation: 2182
In one XAML window, I have two seperate ItemsControls
for different ViewModels
. The ItemsControls
both have grids where the first columns should be the same width. Right now I have the following, but the grids just manage their size independently. I want the first columns to be the same width. Here is my XAML
<TabControl>
<TabItem Header="x">
<Grid Grid.IsSharedSizeScope="True">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid Margin="10" Grid.Row="0" Grid.IsSharedSizeScope="True">
<ItemsControl Name="inputs1" Grid.IsSharedSizeScope="True">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" SharedSizeGroup="1" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock VerticalAlignment="Center" Text="{Binding Description}" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
<Grid Margin="10" Grid.Row="1" Grid.IsSharedSizeScope="True">
<ItemsControl Name="inputs2" Grid.IsSharedSizeScope="True">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="0,0,0,5">
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="1" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock VerticalAlignment="Center" Text="{Binding Description}" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</Grid>
</TabItem>
</TabControl>
They have the same sharedsizegroup so they should be equal right? Result now: https://gyazo.com/2284485127427673269dfd8e26e42682
Upvotes: 0
Views: 158
Reputation: 13448
Remove all Grid.IsSharedSizeScope="True"
properties in the lower hierarchy levels and only keep it in the control that spans all your involved grids. It seems that for each of these properties, a new shared scope is opened, so higher level scopes are ignored (though I couldn't really read that from documentation).
Upvotes: 2