1

What control should I choose in order to deposit a large amount of words with lots of line breaks and a way to highlight the current line. Like a debugger, if i am at the line x I want that line to be colored or something. I've added a small portion of code to give you an example and I also thought that a rich textbox should be good, any suggestions on what should I use ?(my program is a debugging simulator)

Example of what i want the text to look like (colour-wise),

 #include <iostream> 
using namespace std;
int a,b;
..........
return 0;
}
Sam
  • 7,252
  • 16
  • 46
  • 65
Vlad Vlad
  • 132
  • 2
  • 13
  • 2
    That looks like C/C++, not C#... – Sam Jul 04 '13 at 12:54
  • Since his programm is a debugging simulator, I think the code is an example of how the text could look like. – Florian Gl Jul 04 '13 at 12:56
  • 1
    Is that the code you're developing your application in or just a sample of what you want to display in that textbox? – Avram Tudor Jul 04 '13 at 12:56
  • That is an code example of what I would like to add to the specific control dynamically. I want to make a debugger simulator but I don't know what control would be the best for this kind of work. My first idea is to use a rich text box. – Vlad Vlad Jul 04 '13 at 12:58
  • If you happen to post something similar (code wise) please state that in your question next time, otherwise it can be quite misleading. – Sam Jul 04 '13 at 13:12

4 Answers4

1

In WPF you should use RichTextBox as it gives you a wide area of customization options for its content.

Anyway, you should really think in the beginning about all the things you want to do in control, and if you don't find it satisfactory, you'll always have the option to create a custom control with the functionality you want.

Avram Tudor
  • 1,468
  • 12
  • 18
1

Check out the AvalonEdit control and its sample could be found here.

http://www.codeproject.com/Articles/42490/Using-AvalonEdit-WPF-Text-Editor

JSJ
  • 5,653
  • 3
  • 25
  • 32
  • I've tried all the answers and this one is the thing I need but please could you tell me how can I edit just one line at a time, for example to edit the text on just one line no the whole text. – Vlad Vlad Jul 04 '13 at 20:24
0

I would highly recommend using Scintilla, which has a .NET port, and you can embed this control in WPF using the method mentioned here.

Moo-Juice
  • 38,257
  • 10
  • 78
  • 128
  • Hosting a Windows Forms control in WPF is possible but can lead to a subpar visual experience because the control renders using GDI and WPF uses DirectX. Also, the control doesn't integrate well with the WPF layout engine making fluent layouts hard or impossible. – Martin Liversage Jul 04 '13 at 13:32
0

if you are interested in large amount of words, you should think about virtualization of data using the regular WPF ListView.

Refer to this great SO anwer for more information.

However, it sounds like you don't really intent to have large quantities of data, and in that case the other answers here will suit you better.

Community
  • 1
  • 1
Liel
  • 2,407
  • 4
  • 20
  • 39