I wish to create two buttons which will appear next to the editor.
On one button whilst the mousedown I wish to scroll the richtexteditor down. On MouseUp it will stop scrolling.
I then wish for another button to do the same thing but scroll the richtexteditor Up.
Thanks for any instance.
Dave
Hello,
I have been looking into your requirement and created a small sample with XamRichTextEditor and two buttons Up/Down.
In order to get the vertical scrollbar and be able to modify it on button click or any other event you could use the following code:
var scrollBar = Utilities.GetDescendantFromType((this.xrte1), typeof(ScrollBar), true) as ScrollBar;
After that you could change the scroll bar value using its Value property:
void scrolling (ScrollBar scrollBar, string direction) { if(direction == "up") { while (true) { this.Dispatcher.Invoke((Action)(() => { scrollBar.Value -= scrollBar.SmallChange; })); Thread.Sleep(300); } } else { while (true) { this.Dispatcher.Invoke((Action)(() => { scrollBar.Value += scrollBar.SmallChange; })); Thread.Sleep(300); } } }
In order to keep scrolling till the mouse is up, I'm using a thread that would start and call the scrolling method until it is aborted in the button PreviewMouseUp event handler.
I have attached my sample below. Please test it on your side and let me know if I may be of any further assistance.
Sincerely,
Teodosia Hristodorova
Associate Software Developer
5415.XamRichTextEditor_scroll_buttons.zip
Hi Teodosia
Thanks that works great, just one more query on this. I have an OK button on the form as well. I wish for this to be enabled once the user has scrolled through the text (it is a Terms and Conditions type agreement).
Thank you so much for your help.Dave