How can a WPF UserControl inherit a WPF UserControl?

前端 未结 5 1396
独厮守ぢ
独厮守ぢ 2020-11-28 21:46

The following WPF UserControl called DataTypeWholeNumber which works.

Now I want to make a UserControl called DataTypeDateTime and

5条回答
  •  醉酒成梦
    2020-11-28 22:32

    I ran into the same issue but needed to have the control inherit from an abstract class, which is not supported by the designer. What solved my problem is making the usercontrol inherit from both a standard class (that inherits UserControl) and an interface. This way the designer is working.

    //the xaml
    
        ...
    
    
    // the usercontrol code behind
    public partial class UC_BatimentAgricole : EcranFiche, IEcranFiche
    {
        ...
    }
    
    // the interface
    public interface IEcranFiche
    {
       ...
    }
    
    // base class containing common implemented methods
    public class EcranFiche : UserControl
    {
        ... (ex: common interface implementation)
    }
    

提交回复
热议问题