Problem:
When assigning value to the RichTextBox and there is larger text and vertical scrolling of the control display then it will scroll to bottom instead of scroll bar to top which need to fix. Which you can see in the Image 1.
Image 1 |
The solution to the above mentioned problem is very easy as when used the RichTextBox control for my one of application I also see this problem and have to fix the problem as it is not good that control go to the bottom of the text instead of showing the start of the text. I have use same example code from my last post "Silverlight RichTextBox Control For Beginners " Just modified the layout of the page so that both the RichTextBox binding string and Xaml property of the RichTextBox have vertical scroll bars.The modified code of the property changed event of the view model is listed in List 1 here you can see that I have used the ContentStart property of the RichTextBox control to get the start of the content of the RichTextBox control.
List 1
The ContentStart are stored in the TextPointer and then in the next statement I have used the Selection.Select by providing the start pointer to the selection and it will move at the start of the content of the RichTextBox.You can see the output in the Image 2 where you can see that first RichTextBox is scrolled at bottom but the second on is scrolled at top which we want to achieved.
Image 2 |
As I have mentioned in my post that I have used the sample of my last post "Silverlight RichTextBox Control For Beginners " , So you can get source code from above link and test the code which I have listed in List 1 and you have to made some GUI modification as well so that both the RichTextBox control have the vertical scroll bars.
All and any comments / bugs / suggestions are welcomed!
1 comment:
Customize setting of RichTextBox control
Post a Comment