首页 新闻 赞助 找找看

通过DataBinding控制Window的高度只能使用双向绑定?

0
悬赏园豆:5 [待解决问题]

使用数据绑定控制Window的高度, 使用如下XMAL片段不能生效。

Height="{Binding HeightSlider.Value"}


但是如果设置为双向绑定就OK,如下

Height="{Binding HeightSlider.Value,Mode=TwoWay}"


后来发现Window的Left, Top, Height, Width都是这样的,必须使用双向绑定才行。

这是为什么?MSDN中有什么有用的信息吗?

感谢dudu的线索。

StackOverflow除了dudu提供的那个帖子外,还有两个类似的帖子,但是都没有该问题的最终的结论。

http://stackoverflow.com/questions/23426020/window-wpf-height-is-not-bound-to-the-model-property

http://stackoverflow.com/questions/28649856/window-height-and-width-binding-only-one-is-fetched-from-datacontext

WPF
TJC2015的主页 TJC2015 | 初学一级 | 园豆:194
提问于:2015-06-03 10:38
< >
分享
所有回答(1)
0

参考 Problems with binding to Window Height and Width 

这个回答也许是一个线索:

I had the same problem and I noticed that it depends whether height or width is written first in xaml. If height is first, then Binding work only for it and vice versa. The solution was to set Binding mode to 'TwoWay': The project I have made was with MS Studio 2010 and .NET 4.0.

dudu | 园豆:31075 (高人七级) | 2015-06-03 10:52
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册