绑定视口的宽度和高度

时间:2014-10-07 02:26:05

标签: c# wpf xaml data-binding binding

我需要绑定到视口的width和height属性。我试过这个:

Viewport="15,15,binding Path=Width ElementName=LayerNormalThumb,binding Path=HeightElementName=LayerNormalThumb"

如果我只有一个属性,那么这样的绑定对我有用,ex Source =“{binding ...}”。

我也试过这个:

<VisualBrush.Viewport>
   <Rect X="15" Y="15" Width="{Binding ElementName=LayerNormalThumbnail, Path=Width}" Height="{Binding ElementName=LayerNormalThumbnail, Path=Height}"/>
</VisualBrush.Viewport>

我觉得它会起作用,但我得到了

  

不能在'Rect'类型的'Height'属性上设置'Binding'。一个   'Binding'只能在a的DependencyProperty上设置   的DependencyObject。

0 个答案:

没有答案
相关问题