I am trying to have multiple XamDataGrids share some columns between them. This is same functionality the the WPF layout Grid works with it's SharedSizeGroup on column definitions. This is what I have so far, but it doesn't seem to work...
<Window.Resources> <ItemsPanelTemplate x:Key="Template"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" SharedSizeGroup="ColumnA"/> <ColumnDefinition Width="2*" SharedSizeGroup="ColumnB"/> <ColumnDefinition Width="3*"/> <ColumnDefinition Width="4*"/> </Grid.ColumnDefinitions> </Grid> </ItemsPanelTemplate> </Window.Resources> <StackPanel Grid.IsSharedSizeScope="True"> <DataPresenter:XamDataGrid BindToSampleData="False" Name="grid1" Grid.Row="0" AutoFit="True"> <DataPresenter:XamDataGrid.FieldLayoutSettings> <DataPresenter:FieldLayoutSettings AutoGenerateFields="False" DataRecordCellAreaGridTemplate="{StaticResource Template}"> </DataPresenter:FieldLayoutSettings> </DataPresenter:XamDataGrid.FieldLayoutSettings> <DataPresenter:XamDataGrid.FieldLayouts> <DataPresenter:FieldLayout> <DataPresenter:FieldLayout.Fields> <DataPresenter:Field Column="0" Width="Auto" Name="Name" Label="Column A"></DataPresenter:Field> <DataPresenter:UnboundField Width="*" BindingPath="Age" Label="Column B"></DataPresenter:UnboundField> <DataPresenter:UnboundField Width="*" BindingPath="Gender" Label="Column C"></DataPresenter:UnboundField> <DataPresenter:UnboundField Width="*"></DataPresenter:UnboundField> </DataPresenter:FieldLayout.Fields> </DataPresenter:FieldLayout> </DataPresenter:XamDataGrid.FieldLayouts> </DataPresenter:XamDataGrid> <DataPresenter:XamDataGrid BindToSampleData="False" Name="grid2" Grid.Row="1" AutoFit="True"> <DataPresenter:XamDataGrid.FieldLayoutSettings> <DataPresenter:FieldLayoutSettings AutoGenerateFields="False" DataRecordCellAreaGridTemplate="{StaticResource Template}"> </DataPresenter:FieldLayoutSettings> </DataPresenter:XamDataGrid.FieldLayoutSettings> <DataPresenter:XamDataGrid.FieldLayouts> <DataPresenter:FieldLayout> <DataPresenter:FieldLayout.FieldSettings> <DataPresenter:FieldSettings AllowResize="False"></DataPresenter:FieldSettings> </DataPresenter:FieldLayout.FieldSettings> <DataPresenter:FieldLayout.Fields> <DataPresenter:Field Width="Auto" Column="0" Name="Name" Label="Column A"></DataPresenter:Field> <DataPresenter:UnboundField Width="*" BindingPath="Age" Label="Column B"></DataPresenter:UnboundField> <DataPresenter:UnboundField Width="*" BindingPath="Gender" Label="Column C"></DataPresenter:UnboundField> <DataPresenter:UnboundField Width="*"></DataPresenter:UnboundField> </DataPresenter:FieldLayout.Fields> </DataPresenter:FieldLayout> </DataPresenter:XamDataGrid.FieldLayouts> </DataPresenter:XamDataGrid> </StackPanel> </Window>
<Window.Resources>
<ItemsPanelTemplate x:Key="Template">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="ColumnA"/>
<ColumnDefinition Width="2*" SharedSizeGroup="ColumnB"/>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="4*"/>
</Grid.ColumnDefinitions>
</Grid>
</ItemsPanelTemplate>
</Window.Resources>
<StackPanel Grid.IsSharedSizeScope="True">
<DataPresenter:XamDataGrid BindToSampleData="False" Name="grid1" Grid.Row="0" AutoFit="True">
<DataPresenter:XamDataGrid.FieldLayoutSettings>
<DataPresenter:FieldLayoutSettings AutoGenerateFields="False" DataRecordCellAreaGridTemplate="{StaticResource Template}">
</DataPresenter:FieldLayoutSettings>
</DataPresenter:XamDataGrid.FieldLayoutSettings>
<DataPresenter:XamDataGrid.FieldLayouts>
<DataPresenter:FieldLayout>
<DataPresenter:FieldLayout.Fields>
<DataPresenter:Field Column="0" Width="Auto" Name="Name" Label="Column A"></DataPresenter:Field>
<DataPresenter:UnboundField Width="*" BindingPath="Age" Label="Column B"></DataPresenter:UnboundField>
<DataPresenter:UnboundField Width="*" BindingPath="Gender" Label="Column C"></DataPresenter:UnboundField>
<DataPresenter:UnboundField Width="*"></DataPresenter:UnboundField>
</DataPresenter:FieldLayout.Fields>
</DataPresenter:FieldLayout>
</DataPresenter:XamDataGrid.FieldLayouts>
</DataPresenter:XamDataGrid>
<DataPresenter:XamDataGrid BindToSampleData="False" Name="grid2" Grid.Row="1" AutoFit="True">
<DataPresenter:FieldLayout.FieldSettings>
<DataPresenter:FieldSettings AllowResize="False"></DataPresenter:FieldSettings>
</DataPresenter:FieldLayout.FieldSettings>
<DataPresenter:Field Width="Auto" Column="0" Name="Name" Label="Column A"></DataPresenter:Field>
</StackPanel>
</Window>
I guess I should mention that I am using the latest version of the XamDataGrid.
Hi Alex,
I need to get a grid with a nested layout synchronizing the top layout's field width's with the child layout. I looked at http://blogs.infragistics.com/blogs/josh_smith/archive/2008/07/02/synchronizing-field-widths-between-fieldlayouts-in-xamdatagrid.aspx but when I run the sample with the latest version 10.3 of the grid it doesnt work.
Please can you check this sample and update it ASAP?
Regards,Doug Rees
Polo Ralph Lauren
Alright, thanks for your help. I'm not sure if those solutions will help but I'll give it a try.
Hello,
To the best of my knowledge, this will not work with the XamDataGrid and its Fields. What you can try is bind the widths of the fields to each other, like shown in this sample (here the fields of two layouts are bound) or synchronize this manually.
Anyone?