How to load a resource dictionary control template in code for a calendar control

I have a WPF calendar calendar and the template for the day has a property

cal.DayTemplate = 

      

I created a dictionary file associated with my control template for the calendar day

But I'm not sure how to load it into a property DayTemplate

.

I added a dictionary to Application.Resources

inApp.xaml

x:Key

to my control template x:Key="DayTemplate"

So while for download this will work

cal.DayTemplate = new DataTemplate("DayTemplate");

      

+1


source to share


1 answer


Edit: Oops. It's been a while since I had to do this.

I believe you want:



cal.DayTemplate = (DataTemplate)Application.Current.FindResource("DayTemplate");

      

See if this works.

+1


source







All Articles