Hello,
I am using the XamRichTextEditor control and I'm trying to figure out how I can change the default values for the font name and size.
I am NOT interested when loading content into the editor. I am interested when the end user starts typing in the editor when the editor is completely empty/blank.
The initial font size is 11 and the font name is null but it's themed "Minor".
I've already tried changing the DefaultCHaracterSettings property on the RootNode object, but that doesn't actually work. I've also tried changing the character settings on the first ParagraphNode created by the editor by default, but that only temporarily fixes it. I am assuming that those font name/size initial values come from somewhere in the editor object and I want to know where so I can overwrite them.
Any ideas?
Hello Corneliu,
Thank you for your post!
To change the initial font settings of the XamRichTextEditor, you will need to set the character settings on the XamRichTextEditor.Document. You can do this by using the ApplyCharacterSettings method on the RichTextDocument object that represents this document. That method will take a DocumentSpan as its first parameter. Since it is the initial load of the XamRichTextEditor, I would recommend setting that to DocumentSpan.All. The next parameter is your CharacterSettings object, and finally it takes an out string error, in case something goes wrong.
Regarding the font family query, each CharacterSettings object has a FontSettings property. This takes a FontSettings object, which has Ascii, ComplexScript, EastAsia, and HighAnsi properties for their different corresponding script characters. In your corresponding property, you will want to place the string name of the font family that you wish to apply. Most commonly, you will likely be using the Ascii property for the English language.
I have attached a sample project to demonstrate the above. I hope this helps you.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
Hello Andrew,
Your sample solution and detailed answer solved my problem so thank you for that.
Though while testing I came across another issue. It's related to this topic but it's not the same. I can create another post if you think that's best. Until then I'll just post the scenario
Scenario:Using your sample, after typing some content (using the same font name/size), I am trying to change the font size to "36" for all the text that follows. I am using Selection.ApplyFontSize(36). Notice that the keyboard cursor's height is the same with the previous font size (18), not the new one (36). Once I type something, the keyboard cursor will change its height to the current font size (36). The content font size is right, but the cursor is not right prior to typing.
Am I applying the font size properly using the selection property? do I need to do something extra so the cursor also changes its height?
Thanks!