command

Programmatically raise a command

风格不统一 提交于 2020-11-30 20:34:35
问题 I have a button: <Button x:Name="MyButton" Command="SomeCommand"/> Is there a way to execute the command from source? Calling the click on the button does not help: MyButton.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); I mean - this does raise the event, but it does not raise the command. Is there something similar to this RaiseEvent but just for Command? If there is not - how can I instantiate ExecutedRoutedEventArgs ? Is it possible? Lastly - please do not tell me how to avoid

Programmatically raise a command

℡╲_俬逩灬. 提交于 2020-11-30 20:34:24
问题 I have a button: <Button x:Name="MyButton" Command="SomeCommand"/> Is there a way to execute the command from source? Calling the click on the button does not help: MyButton.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); I mean - this does raise the event, but it does not raise the command. Is there something similar to this RaiseEvent but just for Command? If there is not - how can I instantiate ExecutedRoutedEventArgs ? Is it possible? Lastly - please do not tell me how to avoid

Programmatically raise a command

对着背影说爱祢 提交于 2020-11-30 20:34:12
问题 I have a button: <Button x:Name="MyButton" Command="SomeCommand"/> Is there a way to execute the command from source? Calling the click on the button does not help: MyButton.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); I mean - this does raise the event, but it does not raise the command. Is there something similar to this RaiseEvent but just for Command? If there is not - how can I instantiate ExecutedRoutedEventArgs ? Is it possible? Lastly - please do not tell me how to avoid