XAML: access to controls inside user control

前端 未结 3 763
有刺的猬
有刺的猬 2021-01-14 08:45

I have userControl like this:


    

        
3条回答
  •  日久生厌
    2021-01-14 09:46

    I found the solution.

    
    
    
        
        
    
    
    
    

    And in C# code :

    public static readonly DependencyProperty TitleProperty = DependencyProperty.Register("Title", typeof (String), typeof(MyButton),null);
    
        public String Title
        {
            get { return (String)GetValue(TitleProperty); }
            set { SetValue(TitleProperty, value); }
        }
    

    And then in everywhere you can use like this:

    
    

提交回复
热议问题