// Property
IsSelectedProperty = DependencyProperty.Register("IsSelected", typeof(bool), typeof(MyControl),new UIPropertyMetadata(false,
new PropertyChangedCallback(OnIsSelectedChanged)));
// Event
public event RoutedEventHandler SelectedChanged
{
add { AddHandler(SelectedChangedEvent, value); }
remove { RemoveHandler(SelectedChangedEvent, value); }
}
// How Do I Raise the Event ???
static void OnIsSelectedChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)
{
var s = (MyControl)source;
// ????
s.OnSelectedChanged(source, EventArgs.Empty);
答案 0 :(得分:0)
如果您要筹集RoutedEvent
,请致电this.Raise(...);
如果您使用静态方法调用,请按以下方式调用它:
((MyControl)s).Raise( new RoutedEventArg( MyControl.MyEvent ) );