Question

I am trying to embed multiple grids within another grid using an ItemsControl and have all the child grids share the same row heights:

<Grid>
    <ItemsControl ItemsSource="{Binding ControlItems}">
        <ItemsControl.ItemsPanel>
            <CustomPanel></CustomPanel>
        </ItemsControl.ItemsPanel>
        <ItemsControl.DataTemplate>
            <CustomControl/>
        </ItemsControl.DataTemplate>
    </ItemsControl>
</Grid>

Where CustomControl is actually a customized Grid something like this:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition SharedSizeGroup="CustomControlGroup" />
        <RowDefinition SharedSizeGroup="CustomControlGroup" />
    <Grid.RowDefinitions>
</Grid>

However the rows in the child grids do not share the same size?

Was it helpful?

Solution

Well according to this article. You must set the IsSharedSizeScope property in a parent control to True. So probably it should look more like:

<ItemsControl Grid.IsSharedSizeScope="True">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition SharedSizeGroup="CustomControlGroup" />
            <RowDefinition SharedSizeGroup="CustomControlGroup" />
        <Grid.RowDefinitions>
    </Grid>
</ItemsControl>

Here is another example from the MSDN. IMHO, the first article is more understandable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top