big*_*7bb 13 visual-studio-2010 code-snippets
我在VS2010中创建了一个代码片段.当我开始输入时,它没有显示为快捷方式.我把它称为恶作剧.
它在我使用Ctrl-K,Ctrk-X时可用,但是当我刚开始键入prop时...它没有显示为选项.
我错过了某种设置吗?
我有屏幕截图,但我不认为SO允许你上传任何.
编辑:屏幕截图
我可以通过Ctrl-K,Ctrl-X看到我的片段(当我按住Ctrl-PrtScn截取屏幕时它变灰了)

但它不会与其他代码段快捷方式一起出现.

代码片段代码(取自本教程)并位于"Documents\Visual Studio 2010\Code Snippets\Visual C#\ My Code Snippets"文件夹中.
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>propnch</Title>
<Shortcut>propnch</Shortcut>
<Description>Code snippet for property and backing field and ensure
that it invokes INotifyPropertyChanigng and INotifyPropertyChanged</Description>
<Author>Abhishek</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<ToolTip>Property type</ToolTip>
<Default>int</Default>
</Literal>
<Literal>
<ID>property</ID>
<ToolTip>Property name</ToolTip>
<Default>MyProperty</Default>
</Literal>
<Literal>
<ID>field</ID>
<ToolTip>The variable backing this property</ToolTip>
<Default>myVar</Default>
</Literal>
</Declarations>
<Code Language="csharp"><![CDATA[
private $type$ $field$;
public $type$ $property$
{
get
{
return $field$;
}
set
{
this.OnPropertyChanging("$property$");
$field$ = value;
this.OnPropertyChanged("$property$");
}
}
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
Run Code Online (Sandbox Code Playgroud)
事实证明这是VS2010中xml编辑器的设计缺陷.在C#编辑器中,只需输入快捷方式并按"标签"即可.在xml编辑器中,它需要再进行两次击键.
To insert snippets using the shortcut name
1. Position the cursor where you want to insert the XML snippet.
2. Type < in the editor pane.
3. Press ESC to close the IntelliSense complete word list.
4. Type the shortcut name of the snippet, and press TAB to invoke the XML snippet.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5541 次 |
| 最近记录: |