开发者

Where does a class derived from CustomControl get its resources from?

For the Resources property of CustomControl where does it's contents come from and how can I add resources to it in XAML? Is Themes/Generic.xaml the best place? Do I need to do some kind of resource merge in the code for the control?

The following can load resources on the fly but I think this ma开发者_如何转开发y be slow if it's called often.

 System.Uri resourceLocater = new System.Uri("/Themes/Generic.xaml", System.UriKind.Relative);
 ResourceDictionary d = (ResourceDictionary)Application.LoadComponent(resourceLocater);


You can place resources in the Style.Resources of the default style, however the access of those reasources should be limited to within that style anyway. If they are only needed within the Template you can also use the ControlTemplate.Resources.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜