Want more features on Pastebin? Sign Up, it's FREE!
Guest

ICommand snippet

By: a guest on Sep 20th, 2012  |  syntax: C#  |  size: 1.47 KB  |  views: 120  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  3.   <CodeSnippet Format="1.0.0">
  4.     <Header>
  5.       <Title>ICommand property (mvvm)</Title>
  6.       <Shortcut>ic</Shortcut>
  7.       <Description>Code snippet for adding a new ICommand</Description>
  8.       <Author>Ralf de Kleine</Author>
  9.       <SnippetTypes>
  10.         <SnippetType>Expansion</SnippetType>
  11.       </SnippetTypes>
  12.     </Header>
  13.     <Snippet>
  14.       <Imports>
  15.         <Import>
  16.           <Namespace>System.Windows.Input</Namespace>
  17.         </Import>
  18.       </Imports>
  19.       <References>
  20.         <Reference>
  21.           <Assembly>PresentationCore.dll</Assembly>
  22.         </Reference>
  23.       </References>
  24.       <Declarations>
  25.         <Literal>
  26.           <ID>fieldname</ID>
  27.           <ToolTip>Replace with the name of the test class</ToolTip>
  28.           <Default>_action</Default>
  29.         </Literal>
  30.         <Literal>
  31.           <ID>method</ID>
  32.           <ToolTip>Replace with the name of the test class</ToolTip>
  33.           <Default>Action</Default>
  34.         </Literal>
  35.                
  36.       </Declarations>
  37.       <Code Language="csharp"><![CDATA[
  38.           private ICommand $fieldname$Command;
  39.          
  40.           public ICommand $method$Command
  41.           {
  42.                 get
  43.                 {
  44.                         return $fieldname$Command ?? ($fieldname$Command = new RelayCommand(p => $method$(p)));
  45.                 }
  46.           }
  47.          
  48.           public void $method$(object par)
  49.           {
  50.          
  51.           }
  52.           ]]></Code>
  53.     </Snippet>
  54.   </CodeSnippet>
  55. </CodeSnippets>
clone this paste RAW Paste Data