WPF custom RoutedEvent Event code segment, wpfroutedevent

Source: Internet
Author: User

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>

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.