private void Button_Click(object sender, RoutedEventArgs e) { Button button = (Button)sender; // MessageBox.Show(button.Name); OpenDoor?.Invoke(sender, new OpenDoorEventArgs { Door = button.DataContext as DoorItem }); }
private void All_Click(object sender, MouseButtonEventArgs e) { TextBlock button = (TextBlock)sender; DoorItem door = button.DataContext as DoorItem; OpenDoor?.Invoke(sender, new OpenDoorEventArgs { ButtonName = "count", Door = button.DataContext as DoorItem }); e.Handled = true; }
private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { TextBlock textblock = (TextBlock)sender; DoorItem door = textblock.DataContext as DoorItem; OpenDoor?.Invoke(sender, new OpenDoorEventArgs { ButtonName = textblock.Name, Door = textblock.DataContext as DoorItem }); e.Handled = true; /* * Button button = textblock.TemplatedParent as Button; * DoorItem door = button.DataContext as DoorItem; */ }
/// <summary> /// Raise the open door event. /// </summary> private static void RaiseOpenDoor() { OpenDoor?.Invoke(null, EventArgs.Empty); }