Suppose there is such a UserControl :

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

The dependency property is declared in its code-behind :

  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 to make a binding to the command from UserControl , the binding occurred to the button button ?

    1 answer 1

    I solved the problem.

    1) It is necessary to give the name UserControl . Suppose x:Name = this .

    2) Bind the button to the parent control and its team.

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