i've got 3.5 wpf user control 2 buttons , i'd able bind commands these buttons via user control's xaml.
x:usercontrol x:name:fou button1command="{binding stuffcommandhandler}" button2command="{binding stuff2commandhandler}" problem above bindings not working. how can bind commands user control's buttons, 2 of them, via xaml?
i've got in usercontrol's code behind , bind button1commandhandler button1.command
private icommand _button1command; public icommand button1commandhandler { { return _button1command; } set { _button1command = value; } }
you have make button1commandhandler dependency property:
public static readonly dependencyproperty buttoncommandproperty = dependencyproperty.register("buttoncommand", typeof(icommand), typeof(twobuttons), new propertymetadata(default(icommand))); public icommand buttoncommand { { return (icommand)getvalue(buttoncommandproperty); } set { setvalue(buttoncommandproperty, value); } } and bind button's command it. if create button code, can bind this:
button.setbinding(button.commandproperty, new binding("buttoncommand") { source = });
Comments
Post a Comment