This is a migrated thread and some comments may be shown as answers.
Rich text containing images scrolling incorrectly.
1 Answer 18 Views
This is a migrated thread and some comments may be shown as answers.
Richard Ellis
Top achievements
Rank 1
Richard Ellis asked on 05 Dec 2012, 02:11 PM
When a RichText document contains only an image (or the first item is an image) it is automatically scrolling to the bottom of the first image.  We had previously fixed this with the following code:

DocumentChanged =>
{
            // Scroll to Top-left of new document
            Dispatcher.BeginInvoke(new Action(() =>
            {
                this.ScrollToHorizontalOffset(0);
                this.ScrollToVerticalOffset(0);
            }));
};

After updating to a newer version of the Telerik Dlls this seems to have stopped working and the problem is back.  Anyone know how to stop this happening?

Originally a support ticket: http://www.telerik.com/account/support-tickets/view-ticket.aspx?threadid=546164

Thanks.

UPDATE:  After further investigation it seems this works fine for when a document is changed - but does not fix when the RichTextBox is in a RadWindow - and the Document is set in the Constructor of the RadWindow.  Is the DocumentChanged event not firing?  Or is the invocation not enough?  Help please.

1 Answer, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 10 Dec 2012, 12:47 PM
Hi Richard,
Indeed, when the first element in a document is a large image, the control gets scrolled to the caret position which is in the bottom-left corner of the image.
I tested the case you mentioned in your update and you are right that the behavior is not as expected. If you set the Document property of the editor in the constructor the DocumentChanged event is actually raised twice. It looks like we use a dispatcher internally in our code and what you can do in order to prevent the document from scrolling is use a construction with two dispatchers as follows:
Dispatcher.BeginInvoke(() =>
Dispatcher.BeginInvoke(() =>
{
    this.ScrollToHorizontalOffset(0);
    this.ScrollToVerticalOffset(0);
}));
Please try that and let us know how it goes.

 
Greetings,
Petya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Asked by
Richard Ellis
Top achievements
Rank 1
Answers by
Petya
Telerik team
Share this question
or