Hello,
I have a couple of questions about the RichTextBox, I want to use this control for basic notes that are made in my application.
The user should be able to use basic format options to format the note, like bold, understrike, italics and color.
Also the text should be spellchecked, besides that I dont need any of the other features of this control.
I am trying to set this up, but have some questions:
- When I set the font in XAML the font of the text remains 12, the font of my contextmenu gets smaller but not the text in the richtextbox? How can I set this font?
- The default settings show some margins below every line, I can remove this using the contextmenu option paragraph. How can I set this in XAML?
- Is it possible to bind to some property that specify if there are spellcheck errors in the text or the number of spellcheck error in the text? So I can for example show a messagebox before the notes are saved which will tell the user that there are still spell check errors.
- I want to use the Alt+Enter key-combination for next line, the enter key will be used to move to the next field, I tried to implement this see below, but cant programmaticaly add a return in the text. How can I accomplish this?
public
class
RichTextbox : RadRichTextBox
{
protected
override
void
OnPreviewKeyDown(System.Windows.Input.KeyEventArgs e)
{
if
((Keyboard.Modifiers == ModifierKeys.Alt && Keyboard.IsKeyDown(Key.Enter)) ||
(Keyboard.Modifiers == ModifierKeys.Alt && Keyboard.IsKeyDown(Key.Return)) ||
(Keyboard.IsKeyDown(Key.RightAlt) && Keyboard.IsKeyDown(Key.Enter)) ||
(Keyboard.IsKeyDown(Key.RightAlt) && Keyboard.IsKeyDown(Key.Return)))
{
//THIS CODE IS NOT WORKING
XamlFormatProvider provider =
new
XamlFormatProvider();
string
text = provider.Export(
this
.Document);
text +=
"\r\n"
;
provider.Import(text);
e.Handled =
true
;
}
else
if
(Keyboard.IsKeyDown(Key.Enter))
{
this
.MoveFocus(
new
TraversalRequest(FocusNavigationDirection.Next));
e.Handled =
true
;
}
else
{
base
.OnPreviewKeyDown(e);
}
}
}
Regards,
Marcel