结合2 VerticalScrollBars一个到另一个 [英] binding two VerticalScrollBars one to another
本文介绍了结合2 VerticalScrollBars一个到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在控制两个文本框,我有两个thems 2 VerticalScrollBar的。 我要绑定的VerticalScrollBars他们之间,如果一个上升的谢胜利也会去等... 是否有可能,如果这样我怎么能做到这一点?
I have two TextBoxes in the control , and I have in both of thems two VerticalScrollBar. I want to bind the VerticalScrollBars between them , if one goes up the secound will go also etc... Is it possible if so how i can do it ?
感谢
推荐答案
不是一个真正的约束力,但它的工作原理:
Not a real binding but it works:
<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);
}
}
(这个例子忽略了横向滚动的可能性的)
这篇关于结合2 VerticalScrollBars一个到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文