How to add Custom Properties to WPF User Control

前端 未结 2 1924
花落未央
花落未央 2021-02-07 04:19

I\'ve my own User Control including a few buttons and etc.

I use this code to bring that UC to screen.



        
2条回答
  •  鱼传尺愫
    2021-02-07 05:06

    You may not have declared your DependencyPropertys correctly. You can find out full details about how to create DependencyPropertys in the Dependency Properties Overview page on MSDN, but in short, they look something like this (taken from the linked page):

    public static readonly DependencyProperty IsSpinningProperty = 
        DependencyProperty.Register(
        "IsSpinning", typeof(Boolean),
    ...
        );
    
    public bool IsSpinning
    {
        get { return (bool)GetValue(IsSpinningProperty); }
        set { SetValue(IsSpinningProperty, value); }
    }
    

    You can find further help in the DependencyProperty Class page on MSDN.

提交回复
热议问题