Table of Contents

Property CurrentSnippet

Namespace
Alternet.Editor.Wpf
Assembly
Alternet.Editor.Wpf.v9.dll

CurrentSnippet

Gets or sets the current ICodeSnippetRange object.

[Browsable(false)]
public virtual ICodeSnippetRange CurrentSnippet { get; set; }

Property Value

ICodeSnippetRange

Examples

Here is how to use a CurrentSnippet 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.CurrentSnippet != null)
            MessageBox.Show(textSource.CurrentSnippet.ID);
    }
}

Here is how to use a CurrentSnippet 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.CurrentSnippet IsNot Nothing Then MessageBox.Show(textSource.CurrentSnippet.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 CurrentSnippet property will contain a ICodeSnippetRange object representing a selected code snippet literal.

The user can navigate between code snippet literals right after the code snippet is inserted by pressing the TAB key.