I have a DataTemplate that uses a x:Key to identify itself, like so:
<DataTemplate
x:Key="myTemplate
>
...
</DataTemplate>
In some other C# code, I have a reference to this DataTemplate, but actually want to retrieve the DataTemplate’s x:Key.
Question:
Is there a way to retrieve a DataTemplate’s x:Key from a DataTemplate, in C#?
You can do it iterating over all the resources and checking their Key.
Then use it with: