Tuesday, April 15, 2014

Syntax Formatting for any Language in WPF C# Textbox

Its really Simple and Easy to format any languge
  1. First You need to install AvalonEdit from Manage NuGet Packages. Use following link to install instructions http://www.nuget.org/packages/AvalonEdit
or Just right click on Project in Solution Explorer and Click Manage NuGet Packages, now click Online and Search Avalon Editor. Then Install AvalonEditor
  1. Just add following code in xaml file.
    xmlns:avalonedit="http://icsharpcode.net/sharpdevelop/avalonedit"
  2. Now add your TextEditor as follow
    <avalonedit:TextEditor SyntaxHighlighting="XML" x:Name="gameListXMLText" Height="200">
  3. Just Change SyntaxHighlighting as you want it could be C#
  4. Now Just load xml file as follow
gameListXMLText.Text = File.ReadAllText("sample.xml");

No comments:

Post a Comment