开发者

XAML control to inherit from templates

开发者 https://www.devze.com 2022-12-21 18:18 出处:网络
What controls are there to inherit from that has the property of Children and supports templating when building a custom usercontrol.

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.

0

精彩评论

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