2011-02-14 1 views
4

Grid.IsSharedSizeScope를 사용하여 Grid의 첫 번째 열에있는 일부 contols 옆에있는 ItemsControl에 의해 표시된 데이터 바인딩 된 컨트롤을 정렬하려고합니다.Grid.IsSharedSizeScope 및 ItemsControl.ItemTemplate WPF 레이아웃 문제

문제는 컨트롤이 수직으로 계속 커지지 않도록 할 수 없다는 것입니다.

어떻게 MaxHeight 속성을 설정하지 않고이 작업을 중단 할 수 있습니까? 나는 다양한 장소에서 VerticalAlignment와 VerticalContentAlignment의 다른 설정을 시도했지만 알아낼 수는 없다. 좋은 두 개의 열이있는 다른 그리드 내부에 옆에 그리드 및 ItemsControl에면을 넣고, 나쁜 중첩 격자에 Grid.IsSharedSizeScope를 사용하려고

<Grid Grid.IsSharedSizeScope="True" > 
    <Grid.RowDefinitions> 
     <RowDefinition SharedSizeGroup="RowOne" /> 
     <RowDefinition SharedSizeGroup="RowTwo" /> 
     <RowDefinition SharedSizeGroup="RowThree" /> 
    </Grid.RowDefinitions> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="Auto" /> 
     <ColumnDefinition Width="Auto" /> 
    </Grid.ColumnDefinitions> 
    <SomeControl Grid.Row="0" Grid.Column="0" /> 
    <SomeControl Grid.Row="1" Grid.Column="0" /> 
    <ItemsControl Grid.Row="0" Grid.Column="1" Grid.RowSpan="3" ItemsSource="{Binding Path=SomeSource}" ItemsPanel="{StaticResource MyHorizontalStackPanel}" > 
      <ItemsControl.ItemTemplate> 
       <DataTemplate> 
        <Grid> 
         <Grid.RowDefinitions> 
          <RowDefinition SharedSizeGroup="RowOne" /> 
          <RowDefinition SharedSizeGroup="RowTwo" /> 
          <RowDefinition SharedSizeGroup="RowThree" /> 
         </Grid.RowDefinitions> 
         <SomeControl Grid.Row="0" /> 
         <SomeControl Grid.Row="1" /> 
         <SomeControl Grid.Row="2" /> 
        </Grid> 
       </DataTemplate> 
      </ItemsControl.ItemTemplate> 
     </ItemsControl> 
    </Grid> 

답변

15

.

여기 내 자신의 어리 석음에 대한 내 자신의 솔루션입니다 : 내가 말을해야 ... 그것은 4 년 이미 지났 있지만

<!-- outer grid (could be a stack panel) --> 
<Grid Grid.IsSharedSizeScope="True"> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="Auto" /> 
     <ColumnDefinition Width="Auto" /> 
    </Grid.ColumnDefinitions> 
    <!-- header --> 
    <Grid Grid.Column="0" Margin="0,10,10,0"> 
     <Grid.RowDefinitions> 
      <RowDefinition SharedSizeGroup="RowOne" /> 
      <RowDefinition SharedSizeGroup="RowTwo" /> 
      <RowDefinition SharedSizeGroup="RowThree" /> 
     </Grid.RowDefinitions> 
     <SomeControl Grid.Row="0" Grid.Column="0" /> 
     <SomeControl Grid.Row="1" Grid.Column="0" /> 
    </Grid> 
    <!-- rows --> 
    <ItemsControl Grid.Column="1" ItemsSource="{Binding Path=SomeSource}"> 
     <ItemsControl.ItemTemplate> 
      <DataTemplate> 
       <Grid> 
        <Grid.RowDefinitions> 
         <RowDefinition SharedSizeGroup="RowOne" Height="Auto" /> 
         <RowDefinition SharedSizeGroup="RowTwo" Height="Auto" /> 
         <RowDefinition SharedSizeGroup="RowThree" Height="Auto" /> 
        </Grid.RowDefinitions> 
        <!-- define your row here --> 
       </Grid> 
      </DataTemplate> 
     </ItemsControl.ItemTemplate> 
    </ItemsControl> 
</Grid> 
+3

... –

+0

+1 ;-) 자신에 너무 가혹하지 않습니다. 이것 대단히 고마워. 당신의 접근 방식은 당신의 질문에있는 예제와 비슷한 것을 사용할 때 머리글에서 나는 끔찍한 깜박임을 없앴습니다. 이전에는 일종의 무한 레이아웃 루프에 빠져 있었지만,이 새로운 접근 방식으로 바로 정렬되었습니다. –