mardi 9 août 2016

Find DataTemplate key from a generic type

I have the following code where I want to make it generic. So for example rather than doing NotificationView vw = new NotificationView(); in my code if the type passed in is of type NotificationView then I want to find a resource from that Type something like type.TryFindResource("").... Is there a way to do it. Please help.

public static DataTemplate getDataTemplate(Type type)
        {

            NotificationView vw = new NotificationView();

            var DataTemplate = vw.TryFindResource("CustomNotificationTemplate") as DataTemplate;
            return DataTemplate;
        }





Aucun commentaire:

Enregistrer un commentaire