locked
StaticResources in DateTemplates RRS feed

  • Question

  • Hi All,

    I have a issue regarding the StaticResource Access in DataTemplate in SL application as it works fine in WPF.

    I have a Resource Dictionary with different DateTemplates defined in it.

    I'm dynamically selecting the DateTemplate based upon the user's selection of data types and they are working fine until I have to add the StaticResources for those DataTemplates.

    I added in the Page.Resources section the StaticResources and  set the ItemSoruce Property of ComboBox which is inside the DataTemplate to that Static Resource but it gave me error tha StaticResource not found.

    Then I added the namespace in Resource Dictionary file as xmlns:local="clr-namespace:MyProject" and try to create the local Grid.Resource and add reference to that local resource but that fails as well . The run time error is MyProject cannot be accessed.

    Can Anybody tell me how can I use the StaticResources in my dataTemplate which is defined in seperate resource dictionary file and accessed randomly at run time.

    Any response would be appreciated 

     

    Thursday, July 8, 2010 7:34 AM

Answers

  • Hi,

       How do you reference your static resource inside datatemplate?

       IMO, you need to get a grip of the resources owner's reference.

       For instance, resoruces defined in page , you can use it like:

       [PageReference].Resources[]

       Resources in App.xaml:

       App.Current.Resources[] 

    Best Regards

    Sunday, July 11, 2010 1:10 AM

All replies

  • Hi,

       How do you reference your static resource inside datatemplate?

       IMO, you need to get a grip of the resources owner's reference.

       For instance, resoruces defined in page , you can use it like:

       [PageReference].Resources[]

       Resources in App.xaml:

       App.Current.Resources[] 

    Best Regards

    Sunday, July 11, 2010 1:10 AM
  • I'm reference the resources as

    this.Resources["myresource"]  to access the page resources in page's code behind file 

    Monday, July 12, 2010 3:43 AM
  • Hi,

       If you are accessing your resources in DataTemplate like above, I am afaid it cant find the resources.

       You may check my above reply

    Best Regards

    Monday, July 12, 2010 7:57 AM