WPF User Control XAML Commands?

You have to make Button1CommandHandler into a dependency property.

You have to make Button1CommandHandler into a dependency property: public static readonly DependencyProperty ButtonCommandProperty = DependencyProperty. Register("ButtonCommand", typeof(ICommand), typeof(TwoButtons), new PropertyMetadata(default(ICommand))); public ICommand ButtonCommand { get { return (ICommand)GetValue(ButtonCommandProperty); } set { SetValue(ButtonCommandProperty, value); } } and then bind your button's Command to it. If you create the button from code, you can bind it like this: button.

SetBinding(Button. CommandProperty, new Binding("ButtonCommand") { Source = this }).

Working better, Button1. Command = ButtonCommand but ButtonCommand is null when control is created which is understandable. However, the Buttoncommand set isn't being fired when then xaml binding happens, so StuffCommandHandler is never fired when hte button is clicked.

What am I missing? – mike Apr 30 '11 at 18:01 I put a break point of the ButtonCommand set and it never fires – mike Apr 30 '11 at 18:16 You have to bind Button1. Command to ButtonCommand.

– svick Apr 30 '11 at 18:55 Button1 is being created dynamically via code, How do you bind a command via code (C#)? – mike Apr 30 '11 at 19:04 @mike, see edited answer. If you just assign the ButtonCommand property to your button's Command when it's not yet initialized, you just assign null to it, it doesn't somehow automagically know where did that null come from.

You have to use binding. – svick Apr 30 '11 at 19:16.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions