Reputation: 153
I have a object named "item" witch is passed to method from XAML
This is what I get on breakpoint:
base {System.Reflection.TypeInfo} = Name = "Country" Full/Name = "Playground.Domain.Country"}
I'm trying to find how can I found of which "Type" is the item by
public class EditorTemplateSelector : DataTemplateSelector
{
public override DataTemplate SelectTemplate(object item,
DependencyObject container)
{
DataTemplate template = null;
var templateName = "NotFoundEditor";
if (item != null)
{
FrameworkElement element = container as FrameworkElement;
if (element != null)
{
if (item is City)
templateName = "CityEditor";
else if (item is Country)
templateName = "CountryEditor";
template = element.FindResource(templateName) as DataTemplate;
}
}
return template;
}
but with no luck.
The object item
get its data from
public Type ModelType
{
get { return typeof(T); }
}
Any suggestions?
Upvotes: 0
Views: 174
Reputation: 5688
In the light of your last edit:
If "item" is a "System.Type" and not an instance of it, then use:
if(item == typeof(City))
Upvotes: 1
Reputation: 5688
Could you try to see if you have multiple instance of "Playground" assembly in AppDomain.CurrentDomain.GetAssemblies() ?
This may happen if you're referencing this assembly from another project via a dll reference (you chose via "browse" in "add reference" dialog), and not a project reference.
In other words: this kind of odd things happens when you're referencing two different versions of the same assembly.
[edit] if it's that, it has nothing to do with xaml
Upvotes: 1