﻿<?xml version="1.0" encoding="UTF-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Add a RoutedEvent Registration</Title>
      <Author>Microsoft Corporation</Author>
      <Description>Adds code to register a RoutedEvent. This snippet must be added to a class that derives from UIElement.</Description>
      <Shortcut>wpfre</Shortcut>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>eventHandlerType</ID>
          <ToolTip>Replace with the type of the event handler delegate.</ToolTip>
          <Default>RoutedEventHandler</Default>
        </Literal>
        <Literal>
          <ID>eventName</ID>
          <ToolTip>Replace with the name of the event.</ToolTip>
          <Default>Event1</Default>
        </Literal>
         <Object>
          <ID>ownertype</ID>
          <Type>Control</Type>
          <ToolTip>Replace with the name of the class this snippet is being added to.</ToolTip>
          <Default>Window1</Default>
        </Object>
      </Declarations>
      <Code Language="VB">
        <![CDATA[
          Public Custom Event $eventName$ As $eventHandlerType$

              AddHandler(ByVal value As $eventHandlerType$)
                  Me.AddHandler($eventName$Event, value)
              End AddHandler

              RemoveHandler(ByVal value As $eventHandlerType$)
                  Me.RemoveHandler($eventName$Event, value)
              End RemoveHandler

	      RaiseEvent(ByVal sender As Object, ByVal e As RoutedEventArgs)
        	  Me.RaiseEvent(e)
	      End RaiseEvent
          End Event

    Public Shared ReadOnly $eventName$Event As RoutedEvent = _
                      EventManager.RegisterRoutedEvent("$eventName$", _
                      RoutingStrategy.Bubble, _
                      GetType($eventHandlerType$), GetType($ownerType$))
          ]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>