アプリのいくつかの場所で次のツリー ビューを定義しています。
<TreeView.Resources>
<!-- Default Data template for common ParamterType, this displays ParamterType into text box, and do required validation checks on user inputs -->
<DataTemplate DataType="{x:Type src:ParameterDefinition}">
<StackPanel Orientation="Horizontal" VerticalAlignment="Stretch">
<!-- TextBlock resource definition for displaying validation error messages right after text box -->
<StackPanel.Resources>
<DataTemplate DataType="{x:Type ValidationError}">
<TextBlock FontStyle="Italic" Foreground="Red" HorizontalAlignment="Right" Margin="4" Text="{Binding Path=ErrorContent}"/>
</DataTemplate>
</StackPanel.Resources>
<!-- TextBlock for Name of ParameterType -->
<TextBlock Text="{Binding Path=Name}" Width="200"/>
<!-- TextBox for Value of ParameterType -->
<TextBox Name="parameterTxt" HorizontalAlignment="Left" Width="50" TextAlignment="Right">
<TextBox.Resources>
<src:LvDataResource x:Key="max" BindingTarget="{Binding Path=MaxValue}" />
<src:LvDataResource x:Key="min" BindingTarget="{Binding Path=MinValue}" />
<src:LvDataResource x:Key="default" BindingTarget="{Binding Path=Default}" />
</TextBox.Resources>
<TextBox.Text>
<Binding Path="Value" NotifyOnValidationError="True" ValidatesOnDataErrors="True" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay">
<Binding.ValidationRules>
<src:LvDataValidation
MinimumValue="{src:LvDataResourceBinding DataResource={StaticResource min}}"
MaximumValue="{src:LvDataResourceBinding DataResource={StaticResource max}}"
DefaultValue="{src:LvDataResourceBinding DataResource={StaticResource default}}" />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<!-- TextBlock to display validation errors right after text box -->
<TextBlock Width="20"/>
<ContentPresenter Content="{Binding ElementName=parameterTxt, Path=(Validation.Errors).CurrentItem}"/>
</StackPanel>
</DataTemplate> </TreeView.Resources>
この treeview.resources をテンプレートなどに抽出して、このコードのコピーを作成する必要がないようにする方法はありますか?