I've build a datagrid which has a custom column:
<DataGridTemplateColumn
Header="{x:Static local:MainWindowResources.gasNameLabel}"
Width="*"
MinWidth="150">
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<TextBox
Name="GasNameTextBox"
Text="{Binding Path=Name, UpdateSourceTrigger=PropertyChanged}"
Padding="2,0,0,0" />
<DataTemplate.Triggers>
<Trigger
SourceName="GasNameTextBox"
Property="IsVisible"
Value="True">
<Setter
TargetName="GasNameTextBox"
Property="FocusManager.FocusedElement"
Value="{Binding ElementName=GasNameTextBox}"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label
Name="GasNameLabel"
Content="{Binding Path=Name}"
Padding="0,0,0,0"
Margin="6,2,2,2" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
As I am going to be reusing such column definition A LOT, I would really like to define it as an external DataTemplate to which I only provide the property to bind on (Binding Path= ...) and that the rest is reused...that way I would define Text template, Checkbox template and such and reuse them in various grids and only change bindings to different properties.
Is that possible?
Vladan