void ColorPicker_Closed(object sender, EventArgs e) { Ai.Hong.Controls.ColorPicker colorPop = sender as Ai.Hong.Controls.ColorPicker; if (colorPop == null || colorPop.selectedBursh == null) { return; } RoutedPropertyChangedEventArgs <SolidColorBrush> args = new RoutedPropertyChangedEventArgs <SolidColorBrush>(null, (SolidColorBrush)colorPop.selectedBursh); args.RoutedEvent = ColorChangedEvent; RaiseEvent(args); }
/// <summary> /// 按钮点击消息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Click(object sender, RoutedEventArgs e) { if (sender == btnColor) { Ai.Hong.Controls.ColorPicker colorPop = new Ai.Hong.Controls.ColorPicker(); colorPop.Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint; colorPop.Closed += ColorPicker_Closed; colorPop.IsOpen = true; } else if (sender is Button) { RoutedEventArgs newarg = new RoutedEventArgs(); newarg.RoutedEvent = ButtonClickedEvent; newarg.Source = sender; RaiseEvent(newarg); } }