What controls are there to inherit from that has the property of Children and supports templating when building a custom usercontrol.
Currently I know about Panel, but it does not support prope开发者_高级运维rties and methods like DefaultStyleKey and GetTemplateChild();
Is there an interface that I can inherit from for templates such as:
public class Scroller : Panel, ITemplates //Something like ITemplates
{
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
container = GetTemplateChild("container") as StackPanel; //I want to be able to do this
this.Children; //And also be able to use this
}
}
You want ItemsControl. It has an Items property and its template is very flexible as demonstrated by the fact that TabControl, ListBox, ComboBox, etc all derive from it.
精彩评论