Ist es möglich, die mehreren Befehle an die Schaltfläche zu binden.Multiple Command Binding
Ich habe ein Benutzersteuerelement, das ich in meiner Hauptanwendung (Hauptanwendung) anrufe.
Ich möchte einen Klick-Befehl auf beiden Steuerelementen (das Benutzersteuerelement sowie im Hauptfenster) behandeln. Allerdings kann ich nur eins bekommen.
Gibt es eine Möglichkeit, wie ich das bekommen kann.
Jede Hilfe wird wirklich geschätzt.
Code Snippet:
public class MainWindowFooterCommands
{
public static readonly RoutedUICommand FooterClickLocalCommand = new RoutedUICommand("Local Button Command", "FooterClickLocalCommand", typeof(MainWindowFooterCommands));
}
private void MainWindowFooterBindCommands()
{
CommandBinding cmdBindingBXClick = new CommandBinding(MainWindowFooterCommands.FooterClickLocalCommand);
cmdBindingBXClick.Executed += ClickCommandHandler;
CommandBindings.Add(cmdBindingBXClick);
}
void ClickCommandHandler(object sender, ExecutedRoutedEventArgs e)
{
//Do Something
}
//Parent Control holding an instance of the footer control.
class MainWindow {
public MainWindow()
{
CommandBinding cmdBindingBXClick1 = new CommandBinding(MainWindowFooterCommands.BXClickMainWindowCommand);
cmdBindingBXClick1.Executed += LoadParent;
CommandBindings.Add(cmdBindingBXClick1);
}
public void LoadParent(object sender, ExecutedRoutedEventArgs e)
{
LoadParentWindow();
}
}
Grüße, Tushar