以下に示すように、行数と列数の両方が動的なレイアウトを作成しようとしています。
すべてのコントロールを 1 つのグリッドでホストして、上から下、左から右にタブ操作できるようにしたいと考えています。私が動作させようとしているコードを以下に示します。
<Grid base:GridHelpers.RowCount="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=dx:DXWindow}, Path=Groups.Count}" Name="EnclosingGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="180" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!--Labels-->
<ItemsControl ItemsSource="{Binding Rows}" ItemsPanel="{Binding ElementName=EnclosingGrid}">
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="Grid.Row" Value="{Binding RowIndex}" />
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Label Grid.Column="0" Content="{Binding Path=FieldName}" VerticalContentAlignment="Center" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<!--Process fields-->
<ItemsControl ItemsSource="{Binding Cells}" ItemsPanel="{Binding ElementName=EnclosingGrid}">
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="Grid.Row" Value="{Binding ParentRow.RowIndex}" />
<Setter Property="Grid.Column" Value="{Binding ColumnIndex}" />
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBox />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
囲んでいるグリッドに属性を設定しようとしましItemsPanel
たが、残念ながらうまくいきません。
ItemsPanelTemplate
グリッドを内部として設定する唯一の方法はありItemsControl
ますか?
他のアプローチはありますか?または、自分でロールバックする必要がありItemsControl
ますか?