Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
Sharing column widths between XamDataGrids
posted

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>

 

 

I guess I should mention that I am using the latest version of the XamDataGrid.