WPF custom RoutedEvent Event code segment, wpfroutedevent
Today, when I was writing something, I found that RoutedEvent was not found in common code segments. Therefore, I wrote a code segment to facilitate future use. By the way, I recorded how to make a code segment.
1. Create an XML file in the project and change the extension to snippet.
2. open the file, right-click and choose insert code segment> snippet.
3. If the default code segment instance appears, modify the location
4. Get the code Segment directory
The code snippet directory is obtained using the tool-code snippet Manager-location (select the language and list content, and the location will change)
5. Put the custom code segment file in the directory.
6. Call the code segment
7. RoutedEvent code segment
<? Xml version = "1.0" encoding = "UTF-8"?> <CodeSnippet Format = "1.0.0" xmlns = "http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <Header> <Title> routing Event code segment </Title> <Author> routing event </Author> <Shortcut> roue </route cut> <Description> Generate the default route event </Description> <SnippetTypes> <SnippetType> SurroundsWith </SnippetType> <SnippetType> Expansion </SnippetType> </SnippetTypes> </ header> <Snippet> <Declarations> <Literal> <ID> type </ID> <ToolTip> attribute type </ToolTip> <Default> EventHandler </Default> </Literal> <ID> RoutedEventName </ID> <ToolTip> attribute name </ToolTip> <Default> MyEvent </Default> </Literal> </Declarations> <Code Language = "XML"> <! [CDATA [public event $ type $ RoutedEventName $ {add {AddHandler ($ RoutedEventName $ Event, value);} remove {RemoveHandler ($ RoutedEventName $ Event, value );}} public static readonly RoutedEvent $ RoutedEventName $ Event = EventManager. registerRoutedEvent ("$ RoutedEventName $", RoutingStrategy. bubble, typeof ($ type $), typeof (myclass);]> </Code> </Snippet> </CodeSnippet>