I use the following DataTemplate in many controls:
<pages:BasePageManageItems x:Class="TestApp.Pages.PageManageAddresses"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:pages="clr-namespace:TestHistorierung.Pages"
xmlns:tk="http://schemas.microsoft.com/wpf/2008/toolkit"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Background="#eee"
VerticalAlignment="Stretch">
<pages:BasePageManageItems.Resources>
<DataTemplate x:Key="manageAreaCellTemplate">
<Border Padding="2">
<StackPanel Orientation="Horizontal">
<TextBlock Style="{DynamicResource ManageLinkStyle}"
Tag="{Binding Id}" Text="Delete" MouseDown="System_Delete_Click"
Margin="0 0 5 0"/>
<TextBlock Style="{DynamicResource ManageLinkStyle}"
Tag="{Binding Id}" Text="Edit" MouseDown="System_Edit_Click"
Margin="0 0 5 0"/>
<TextBlock Style="{DynamicResource ManageLinkStyle}"
Tag="{Binding Id}" Text="Add" MouseDown="System_Add_Click"
Margin="0 0 5 0"/>
<TextBlock Style="{DynamicResource ManageLinkStyle}"
Tag="{Binding Id}" Text="Copy" MouseDown="System_Copy_Click"
Margin="0 0 5 0"/>
</StackPanel>
</Border>
</DataTemplate>
</pages:BasePageManageItems.Resources>
Is there any way to use XamlReader from XAML so that I can simply load the text of the DataTemplate into the XAML file dynamically? I'm imagining something like this (pseudo code):
<pages:BasePageManageItems x:Class="TestApp.Pages.PageManageAddresses"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:pages="clr-namespace:TestHistorierung.Pages"
xmlns:tk="http://schemas.microsoft.com/wpf/2008/toolkit"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Background="#eee"
VerticalAlignment="Stretch">
<pages:BasePageManageItems.Resources>
<XamlReader Load="XamlBlocks/DateTemplateManageButtons.xaml"/>
</pages:BasePageManageItems.Resources>