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
980
XamGrid - have the same column layout for multiple grids
posted

I have a window with multiple XamGrids but I am going to bind the same data structure to each of them. What is a good way to define the column layout once and then reference that layout with each of the grids? I would like to avoid maintaining multiple versions of the same column layout. For example, the following is from your samples:

<ig:XamGrid x:Name="dataGrid" AutoGenerateColumns="false" ItemsSource="{Binding Path=Customers}" ColumnWidth="*">

   <ig:XamGrid.Columns>

        <ig:TextColumn Key="CustomerID">

            <ig:TextColumn.HeaderTemplate>

                <DataTemplate>

                    <TextBlock Text="{Binding Path=XWG_Customers_CustomerID, Source={StaticResource Strings}}" />

                </DataTemplate>

            </ig:TextColumn.HeaderTemplate>

        </ig:TextColumn>

        <ig:TextColumn Key="Company">

            <ig:TextColumn.HeaderTemplate>

                <DataTemplate>

                    <TextBlock Text="{Binding Path=XWG_Customers_Company, Source={StaticResource Strings}}" />

                </DataTemplate>

            </ig:TextColumn.HeaderTemplate>

        </ig:TextColumn>

        <ig:TextColumn Key="ContactName">

            <ig:TextColumn.HeaderTemplate>

                <DataTemplate>

                    <TextBlock Text="{Binding Path=XWG_Customers_ContactName, Source={StaticResource Strings}}" />

                </DataTemplate>

            </ig:TextColumn.HeaderTemplate>

        </ig:TextColumn>

        <ig:TextColumn Key="ContactTitle">

            <ig:TextColumn.HeaderTemplate>

                <DataTemplate>

                    <TextBlock Text="{Binding Path=XWG_Customers_ContactTitle, Source={StaticResource Strings}}" />

                </DataTemplate>

            </ig:TextColumn.HeaderTemplate>

        </ig:TextColumn>

        <ig:TextColumn Key="Region">

            <ig:TextColumn.HeaderTemplate>

                <DataTemplate>

                    <TextBlock Text="{Binding Path=XWG_Customers_Region, Source={StaticResource Strings}}" />

                </DataTemplate>

            </ig:TextColumn.HeaderTemplate>

        </ig:TextColumn>

        <ig:TextColumn Key="Country">

            <ig:TextColumn.HeaderTemplate>

                <DataTemplate>

                    <TextBlock Text="{Binding Path=XWG_Customers_Country, Source={StaticResource Strings}}" />

                </DataTemplate>

            </ig:TextColumn.HeaderTemplate>

        </ig:TextColumn>

    </ig:XamGrid.Columns>

</ig:XamGrid>

 

Assuming I have this exact same layout for 5 different grids on the window, how would I allow each grid to share this layout?

 

Thanks!