Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

wpf make both rich Text scroll

//You can use the ScrollViewer.ScrollChanged routed event to listen for
//scrolling changes. Example:
// in file.xaml
<UniformGrid Rows="1" Width="300" Height="150" >
    <RichTextBox x:Name="_rich1" 
                 VerticalScrollBarVisibility="Auto"
                 ScrollViewer.ScrollChanged="RichTextBox_ScrollChanged" />
    <RichTextBox x:Name="_rich2" 
                 VerticalScrollBarVisibility="Auto"
                 ScrollViewer.ScrollChanged="RichTextBox_ScrollChanged" />
</UniformGrid>

//Then, in the event handler you do the actual synchronizing
// in file.xaml.cs
private void RichTextBox_ScrollChanged(object sender, ScrollChangedEventArgs e)
{
    var textToSync = (sender == _rich1) ? _rich2 : _rich1;

    textToSync.ScrollToVerticalOffset(e.VerticalOffset);
    textToSync.ScrollToHorizontalOffset(e.HorizontalOffset);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #wpf #rich #Text #scroll
ADD COMMENT
Topic
Name
9+8 =