ここでは用語が間違っているかもしれませんが、添付イベントを作成しようとしています。WPFのカスタム添付イベント
<Grid Background="{StaticResource WindowBackground}" x:Name="Foo" s:SurfaceFrameworkElement.ContactChanged="Foo_ContactChanged"/>
私はハンドラが同じようにXAMLで追加することができたためにカスタムイベントを作成したいが、私はトラブルを抱えている:表面SDKでは
、あなたのようなことを行うことができます。
カスタムルーティングイベントを作成できますが、XAMLインテリセンスには表示されず、イベントハンドラは定期的に入力するだけで追加されません。ここに私のイベントの定義があります:
public static class TagRectEvents
{
public static readonly RoutedEvent TagRectEnterEvent = EventManager.RegisterRoutedEvent(
"TagRectEnter", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TagRectEvents));
public static void AddTagRectEnterHandler(DependencyObject d, RoutedEventHandler handler)
{
UIElement element = d as UIElement;
if (element == null)
{
return;
}
element.AddHandler(TagRectEvents.TagRectEnterEvent, handler);
}
public static void RemoveTagRectEnterHandler(DependencyObject d, RoutedEventHandler handler)
{
UIElement element = d as UIElement;
if (element == null)
{
return;
}
element.RemoveHandler(TagRectEvents.TagRectEnterEvent, handler);
}
}
私はちょうどそれについてすべて間違っていますか?添付のプロパティを追加し、そのプロパティを設定する要素を使用して作業を行う方法については、「添付のビヘイビア」の例のすべてを参照してください。