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
I modified the previously provided sample by adding an OK button that is initially disabled. My suggestion in order to enable it once you reach the end of the scroll is to handle the XamRichTextEditor's scroll bar ValueChanged event. There you could get the current scroll bar value and if it is equal to its maximum value. In this case, you could set the button IsEnabled property back to true.
I have attached a sample application, that uses this approach. Please test it on your side and let me know if I may be of any further assistance.
4505.XamRichTextEditor_scroll_buttons.zip
Thank you Teodosia that worked a treat
I am glad that you find my suggestion helpful.
Thank you for using Infragistics components.
Regards,Teodosia HristodorovaAssociate Software Developer