WPF usercontrol as a factory
I have a situation where I load several usercontrols dynamically. Since all of them inherit from UserControl
, I开发者_运维问答 was wondering if it made sense to make UserControl a Factory and return the appropriate usercontrol based on some condition.
Am I making any sense?
I think you mean whether you can create a UserControlFactory which I believe is fine because at the end of day any control is a class any way and if you need create instances dynamically then you can create a factory for them.
But first see if you can accomplish the same thing with DataTemplate, Trigger, or DataTemplateSelector
http://msdn.microsoft.com/en-us/library/ms742521.aspx
精彩评论