How do you redirect the team from parent control to daughter?



  • Let's say there's one. UserControl:

    <UserControl>
           <Button Name="button"></Button>
    </UserControl>
    

    Him. code-behind The nature of dependence has been embraced:

     public partial class Test : UserControl
    {
        public LoginButton()
        {
            InitializeComponent();
        }
    
    public ICommand Command
    {
        get { return (ICommand)GetValue(CommandProperty); }
        set { SetValue(CommandProperty, value); }
    }
    
    public static readonly DependencyProperty CommandProperty =
        DependencyProperty.Register("Command", typeof(ICommand), typeof(Test));
    

    }

    How do you do to get attached to a team from UserControl, the connection was to the button. button?



  • I figured it out.

    (1) We need a name. UserControl♪ All right. x:Name = this

    (2) Put the button on the parent counter and his team.

    <Button   Command="{Binding Command, ElementName=this}"/>
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2