Hi,
you should use the ValueChanged event insteat of Scroll event:
Instead of
<textbox name="scrlTB1" height="100" scrollbar.scroll="Scroll" scrollviewer.verticalscrollbarvisibility="Visible" />
<textbox name="scrlTB2" height="100" scrollbar.scroll="Scroll" scrollviewer.verticalscrollbarvisibility="Visible" />
private void Scroll(object sender, ScrollEventArgs e)
{
if (sender == scrlTB1)
{
scrlTB2.ScrollToVerticalOffset(e.NewValue);
}
else
{
scrlTB1.ScrollToVerticalOffset(e.NewValue);
}
}
you should try this:
<textbox x:name="txt_1" height="122" textwrapping="Wrap" text="TextBox" scrollviewer.verticalscrollbarvisibility="Visible" scrollbar.valuechanged="ScrollBar_Scroll" scrollviewer.cancontentscroll="True" xmlns:x="#unknown" />
<textbox x:name="txt_2" height="122" margin="346,169,0,0" textwrapping="Wrap" text="TextBox" width="139" scrollviewer.verticalscrollbarvisibility="Visible" scrollbar.valuechanged="ScrollBar_Scroll" scrollviewer.cancontentscroll="True" xmlns:x="#unknown" />
private void ScrollBar_Scroll(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (sender == txt_1)
{
txt_2.ScrollToVerticalOffset(e.NewValue);
}
else
{
txt_1.ScrollToVerticalOffset(e.NewValue);
}
}
</double>
Main properties are:
scrollviewer.verticalscrollbarvisibility="Visible"
scrollbar.valuechanged="ScrollBar_Scroll"
scrollviewer.cancontentscroll="True"
This will work on moving the scroll bar, clicking on the scroll buttons and using the cursor.
I hope this helps.
Regards
Jegan