开发者

Code to access resource inside ResourceDictionary with PRISM+Silverlight

On an application that i'm developing usin开发者_开发问答g Silverlight 4 and PRISM, on one of the modules i have a ResourceDicionary with a DataTemplate.

Is there any way to get an instance of that DataTemplate using just C# code? note that the code should work on any class inside that module, not just on the controls code behind.

thanks in advance.


DataTemplate myDataTemplate = (DataTemplate)Application.Current.Resources["MyDataTemplateKey"]

EDIT: What about next approach?: Create UserControl with name Module as singlton. In Xaml only resources and references on resources. In code behind singleton implementation and property resources that return usercontrol resources. Now, you can use Module as Application in your code:

DataTemplate myDataTemplate = (DataTemplate)Module.Current.Resources["MyDataTemplateKey"]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜