Hi i try to find the generated UIElement from a DataTemplate
but i'm not able to find my UserControl which should be somewhere in my ContentPresenter i looked in to the control via a Breakpoint and Snoop but i cant find the UserControl
can someone please enlight where i can find it?
Here my Test Project:
App XAML
<Application.Resources>
<DataTemplate x:Name="TESTTemplate" DataType="{x:Type vmv:VM}">
<vmv:MyView/>
</DataTemplate>
</Application.Resources>
View
<UserControl ...>
<DataGrid ItemsSource="{Binding MyItems}"/>
</UserControl>
VM
public class VM
{
private ObservableCollection<MyRow> myItems;
public ObservableCollection<MyRow> MyItems
{
get { return myItems; }
set { myItems = value; }
}
public VM()
{
myItems = new ObservableCollection<MyRow>();
myItems.Add(new MyRow { Text = "a", Number = 1 });
myItems.Add(new MyRow { Text = "s", Number = 2 });
myItems.Add(new MyRow { Text = "d", Number = 3 });
myItems.Add(new MyRow { Text = "f", Number = 4 });
}
}
public class MyRow
{
public string Text { get; set; }
public int Number { get; set; }
}
MainWindow XAML
<Window x:Class="MyPrinterAPI.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<StackPanel>
<ContentPresenter Name="CPresenter">
</ContentPresenter>
</StackPanel>
</Window>
CodeBehind
/// <summary>
/// Interaktionslogik für MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
var vm = new VM();
DataContext =vm;
CPresenter.Content = vm;
}
}