Auto scroll to the end of a RichTextBlock after update #7498
Replies: 4 comments
-
I think that the delay is helping you because layout hasn't run yet, so there is no new extent for the scrollviewer to scroll into. I think a better workaround would be to post this to the UI thread using dispatcher runAsync for winui2 or tryEnqueue for winui3. Here on Winui2 (https://docs.microsoft.com/en-us/uwp/api/windows.ui.core.coredispatcher.runasync?view=winrt-19041#Windows_UI_Core_CoreDispatcher_RunAsync_Windows_UI_Core_CoreDispatcherPriority_Windows_UI_Core_DispatchedHandler_) or here on Winui3 https://docs.microsoft.com/en-us/windows/winui/api/microsoft.system.dispatcherqueue.tryenqueue?view=winui-3.0-preview#Microsoft_System_DispatcherQueue_TryEnqueue_Microsoft_System_DispatcherQueueHandler_ ( @RBrid can you weigh in? |
Beta Was this translation helpful? Give feedback.
-
@StephenLPeters
only change you will not have an error message because you are trying to update the UI from a different thread output
i think what helps, is an event, that informs, when the content update is finished |
Beta Was this translation helpful? Give feedback.
-
@StephenLPeters any news? |
Beta Was this translation helpful? Give feedback.
-
@AndreMarschalek On my end I had a RichTextBlock as the content of a ScrollViewer, and listening to SizeChanged events from the RichTextBlock (upon addition/removal of content) did the trick. On the event handler I scroll to the scrollable height, which is then resolved to reflect the content's new size.
|
Beta Was this translation helpful? Give feedback.
-
A RichTextBlock Component is used to present important information. After adding additional content, the RichTextBlock should scroll down to the lowest possible position, to show the user the latest updates.
For Scrolling the RichTextBlock is child of a ScrollViewer:
code behind
In this situation the scrollbar scrolls to the position where the new content starts, not at the end of the new content.
I did not find an event that i can use to implement the ScrollToVerticalOffset command.
ugly workaround
output
What's the way to implement this feature without adding a delay which could add some other problems on different clients?
Beta Was this translation helpful? Give feedback.
All reactions