WPF UserControls - setting the .Command property on button inside UserControl

Posted by Judah Himango on Stack Overflow See other posts from Stack Overflow or by Judah Himango
Published on 2010-05-05T23:29:55Z Indexed on 2010/05/05 23:38 UTC
Read the original article Hit count: 403

Filed under:
|
|
|

I've got a UserControl that contains a button and some other controls:

<UserControl>
  <StackPanel>
     <Button x:Name="button" />
     ...
  </StackPanel>
</UserControl>

When I create a new instance of that control, I want to get at the Button's Command property:

<my:GreatUserControl TheButton.Command="{Binding SomeCommandHere}">
</my:GreatUserControl>

Of course, the "TheButton.Command" thing doesn't work.

So my question is: Using XAML, how can I set the .Command property of the button inside my user control?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about usercontrols