Property CodeSnippets
CodeSnippets
Gets or sets ICodeSnippetRangeList
for Edit control.
[Browsable(false)]
public virtual ICodeSnippetRanges CodeSnippets { get; set; }
Property Value
Examples
Here is how to use a CodeSnippets in the C# code:
using System;
using System.Windows;
using Alternet.Editor.Wpf;
public partial class MainWindow : Window
{
private TextSource textSource;
private void Window_Loaded(object sender, RoutedEventArgs e)
{
var textEdit1 = new TextEditor();
textSource = new TextSource();
textSource.LoadFile("myfile.txt");
textEdit1.Source = this.textSource;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
if ((textSource.CodeSnippets != null) && textSource.CodeSnippets.Count > 0)
MessageBox.Show(textSource.CodeSnippets[0].ID);
}
}
Here is how to use a CodeSnippets in the Visual Basic code:
Imports System
Imports System.Windows
Imports Alternet.Editor.Wpf
Partial Public Class MainWindow
Inherits Window
Private textSource As TextSource
Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim textEdit1 = New TextEditor()
textSource = New TextSource()
textSource.LoadFile("myfile.txt")
textEdit1.Source = Me.textSource
End Sub
Private Sub Button_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
If (textSource.CodeSnippets IsNot Nothing) AndAlso textSource.CodeSnippets.Count > 0 Then MessageBox.Show(textSource.CodeSnippets(0).ID)
End Sub
End Class
Remarks
Code snippets are ready-made snippets of code you can quickly insert into the text. When the user selects a code snippet from the code snippet list (usually invoked by Ctrl + K + X key combination), the CodeSnippets property will contain a collection of ICodeSnippetRange objects, each one is representing a code snippet literal being inserted.