In windows Froms I have a split container in Panle1 I have a WPF richtextbox so I want to synchronize the vertical scrolling of the richtextbox with Panel2 and vis versa. I know how to synchronize scrolling for the Panels.
If you wrap your rich text boxes in a scroll viewer control
<ScrollViewer ScrollChanged="ScrollViewer_ScrollChanged_1" Name="scvOriginal">
<RichTextBox Name="rtbOrginal" ScrollViewer.CanContentScroll="True" />
</ScrollViewer>
<ScrollViewer Name="scvChanged">
<RichTextBox Name="rtbChanged" ScrollViewer.CanContentScroll="True" />
</ScrollViewer>
Then tap into the scroll changed event of the scroll viewer
private void scvOriginal_ScrollChanged(object sender, ScrollChangedEventArgs e)
{
scvChanged.ScrollToVerticalOffset(e.VerticalOffset);
}
This will allow to to set the horizontal and vertical scroll of the 2 rich text boxes.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.