I'm trying to workaround the difficulties in binding to a Dictionary in WinRT Xaml (also referenced here). I want to use a converter to do this rather than having to change all of my view-models or business code to return a List of a custom Key Value class.
This means I need to cast an object to a List<> of some type.
public object Convert(object value, Type targetType, object parameter, string temp)
{
if(value is IDictionary)
{
dynamic v = value;
foreach (dynamic kvp in v)
{
}
}
return //some sort of List<>
}
I don't know how to do this though. When I mouse over the value in the debugger it still remember its appropriate type (like Dictionary) but I don't know how to make use of this at run time.
What do I need to do to cast something of type object (which is guaranteed to actually be a Dictionary<,>) to some sort of List so that I can bind to it in XAML?
Aucun commentaire:
Enregistrer un commentaire