[英]Bind Usercontrol to scrollbar wpf
I'm having a UserControl
which I'm going to use as a Find/Replace UserControl, like the one in Visual studio. 我有一个
UserControl
,它将像Visual Studio中的那样用作查找/替换UserControl。
I'm placing this UserControl
on top of a TextBox
. 我将此
UserControl
放在TextBox
顶部。
Users are able to zoom in and out in the TextBox
, which makes the ScrollBar
and text smaller/bigger. 用户可以在
TextBox
放大和缩小,这使ScrollBar
和文本变小/变大。
So my question: Is it possible to bind my UserControl
to the ScrollBar's width? 所以我的问题是:是否可以将我的
UserControl
绑定到ScrollBar的宽度?
(I could of course listen to the zoom event and calculate the width, but I would like an easier and better approach) (我当然可以监听缩放事件并计算宽度,但是我想使用一种更简单,更好的方法)
也许是这样的吗?
<UserControl Name="uc" Width="{Binding ElementName=scrollBar, Path=ActualWidth}" />
I solved this by: Comparing TextEditor.TextArea.ActualWidth
to TextEditor.ActualWidth
, every time the ScrollBar
became visible and when the user zoomed. 我解决了这个由:比较
TextEditor.TextArea.ActualWidth
到TextEditor.ActualWidth
,每次时间ScrollBar
变得可见,并且当用户放大。 The difference was used to updated the margin of my UserControl
. 差异用于更新
UserControl
的边距。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.