Question: Is it possible to declare `DataGrid` columns in a style or as a resource?
I would like to do something like this:

```
<....Resources>
    <DataGridColumns x:Key="dgcDataGridColumns">
        <DataGridTextColumn />
        <DataGridTextColumn />
    </DataGridColumns
</....Resources>

<DataGrid Columns="{StaticResource dgcDataGridColumns}" />

```

The reason is that i have to share the column definition for 4 different `DataGrids`. Any way to achieve this? Best would be without code behind!

Answer: 
x:Shared helps to avoid the exception MattS423 has got.

```
<Window.Resources>
    <DataGridTextColumn x:Key="dgtcFirstName" x:Shared="False" Header="First Name" Binding="{Binding FirstName}"/>
    <DataGridTextColumn x:Key="dgtcSecondName" x:Shared="False" Header="Second Name" Binding="{Binding SecondName}"/>
</Window.Resources>

<Grid>
    <StackPanel>
        <DataGrid AutoGenerateColumns="False" Height="200" Name="dataGrid1" Width="200">
            <DataGrid.Columns>
                <StaticResource ResourceKey="dgtcFirstName"/>
                <StaticResource ResourceKey="dgtcSecondName"/>
            </DataGrid.Columns>
        </DataGrid>
        <DataGrid AutoGenerateColumns="False" Height="200" Name="dataGrid2" Width="200">
            <DataGrid.Columns>
                <StaticResource ResourceKey="dgtcSecondName"/>
                <StaticResource ResourceKey="dgtcFirstName"/>
            </DataGrid.Columns>
        </DataGrid>
    </StackPanel>
</Grid>

```
I don't think you can, as in that situation you aren't specifying a template or a style, but the actual Column object. I don't think the data grids play nicely when sharing like that; I think you'll get an exception to the extent of "This UIElement is already the child of another UIElement".

So I tried the following...slightly different than what you're talking about. but I got this exception:

{"DataGridColumn with Header '' already exists in the Columns collection of a DataGrid. DataGrids cannot share columns and cannot contain duplicate column instances.\r\nParameter name: item"}

with this XAML:

```
         <Grid.Resources>
            <DataGridTextColumn x:Key="MyColumn" />
        </Grid.Resources>
          <DataGrid>
            <DataGrid.Columns>
                <StaticResource ResourceKey="MyColumn" />
            </DataGrid.Columns>
        </DataGrid>

        <DataGrid>
            <DataGrid.Columns>
                <StaticResource ResourceKey="MyColumn" />
            </DataGrid.Columns>
        </DataGrid>

```