Difference between Control Template and DataTemplate in WPF

前端 未结 7 1520
孤城傲影
孤城傲影 2020-12-07 07:13

What is difference between a ControlTemplate and a DataTemplate in WPF?

7条回答
  •  生来不讨喜
    2020-12-07 07:40

    ControlTemplate: Represents control style.

    DataTemplate: Represents data style(How would you like to show your data).

    All controls are using default control template that you can override through template property.

    For example
    Button template is a control template. Button content template is a data template

    
    
    public String UserName
    {
        get { return userName; }
        set
        {
            userName = value;
            this.NotifyPropertyChanged("UserName");
        }
    }
    

提交回复
热议问题