Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 1st, 2012  |  syntax: None  |  size: 2.91 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. WPF layout problem with Grid.IsSharedSizeScope and ItemsControl.ItemTemplate
  2. <Grid Grid.IsSharedSizeScope="True" >
  3.     <Grid.RowDefinitions>
  4.         <RowDefinition SharedSizeGroup="RowOne" />
  5.         <RowDefinition SharedSizeGroup="RowTwo" />
  6.         <RowDefinition SharedSizeGroup="RowThree" />
  7.     </Grid.RowDefinitions>
  8.     <Grid.ColumnDefinitions>
  9.         <ColumnDefinition Width="Auto" />
  10.         <ColumnDefinition Width="Auto" />
  11.     </Grid.ColumnDefinitions>
  12.     <SomeControl Grid.Row="0" Grid.Column="0" />
  13.     <SomeControl Grid.Row="1" Grid.Column="0" />
  14.     <ItemsControl Grid.Row="0" Grid.Column="1" Grid.RowSpan="3" ItemsSource="{Binding Path=SomeSource}" ItemsPanel="{StaticResource MyHorizontalStackPanel}" >
  15.             <ItemsControl.ItemTemplate>
  16.                 <DataTemplate>
  17.                     <Grid>
  18.                         <Grid.RowDefinitions>
  19.                             <RowDefinition SharedSizeGroup="RowOne" />
  20.                             <RowDefinition SharedSizeGroup="RowTwo" />
  21.                             <RowDefinition SharedSizeGroup="RowThree" />
  22.                         </Grid.RowDefinitions>
  23.                         <SomeControl Grid.Row="0" />
  24.                         <SomeControl Grid.Row="1" />
  25.                         <SomeControl Grid.Row="2" />
  26.                     </Grid>
  27.                 </DataTemplate>
  28.             </ItemsControl.ItemTemplate>
  29.         </ItemsControl>
  30.     </Grid>
  31.        
  32. <Grid DockPanel.Dock="Top"
  33.           Grid.IsSharedSizeScope="True">
  34.         <Grid.ColumnDefinitions>
  35.             <ColumnDefinition Width="Auto" />
  36.             <ColumnDefinition Width="Auto" />
  37.         </Grid.ColumnDefinitions>
  38.         <Grid Grid.Column="0"
  39.               Margin="0,10,10,0">
  40.             <Grid.RowDefinitions>
  41.                 <RowDefinition SharedSizeGroup="RowOne" />
  42.                 <RowDefinition SharedSizeGroup="RowTwo" />
  43.                 <RowDefinition SharedSizeGroup="RowThree" />
  44.             </Grid.RowDefinitions>
  45.             <SomeControl Grid.Row="0" Grid.Column="0" />
  46.             <SomeControl Grid.Row="1" Grid.Column="0" />
  47.         </Grid>
  48.         <ItemsControl Grid.Column="1" ItemsSource="{Binding Path=SomeSource}" ItemsPanel={StaticResource MyHorizontalStackPanel} >
  49.             <ItemsControl.ItemTemplate>
  50.                 <DataTemplate>
  51.                     <Grid>
  52.                         <Grid.RowDefinitions>
  53.                             <RowDefinition SharedSizeGroup="RowOne"
  54.                                            Height="Auto" />
  55.                             <RowDefinition SharedSizeGroup="RowTwo"
  56.                                            Height="Auto" />
  57.                             <RowDefinition SharedSizeGroup="RowThree"
  58.                                            Height="Auto" />
  59.                         </Grid.RowDefinitions>
  60.                         ...
  61.                     </Grid>
  62.                 </DataTemplate>
  63.             </ItemsControl.ItemTemplate>
  64.         </ItemsControl>
  65.     </Grid>