문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top