Wpf GridSplitter 替换 row.height 属性上的绑定
我在网格分割器方面遇到了困难。我已将 RowDefinition.Height
依赖属性绑定到模型的 clr 属性,如下所示。
<Grid.RowDefinitions> <RowDefinition Height='{Binding Path=Height, Mode=OneWay}' /> <RowDefinition Height='*' /> </Grid.RowDefinitions>
在使用 GridSplitter 之前,这一切都可以正常工作。当使用 GridSplitter 手动更改行高时,它会用新的固定大小替换绑定(并删除绑定)。
您是否有任何想法或解决方法如何创建可使用 GridSplitter 调整大小但仍根据 clr 属性/绑定更改其高度的两行?
I'm having a hard time with grid splitter. I've bound the RowDefinition.Height
dependency property to the clr property of the model as presented below.
<Grid.RowDefinitions> <RowDefinition Height='{Binding Path=Height, Mode=OneWay}' /> <RowDefinition Height='*' /> </Grid.RowDefinitions>
This works fine just until the GridSplitter
is used. When the height of the row is changed manually with GridSplitter
, it replaces the binding with the new fixed size (and removes the binding).
Have you got any ideas or workarounds how to create two rows that would be resizable with GridSplitter but still change their height according to the clr property/binding?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为问题在于您的源属性
Height
的类型为 double,而RowDefinition.Height
的类型为GridLength
。使用转换器即可工作 TwoWayDoubleGridLengthConverter
更新
在这里上传了我的示例应用程序:http://www.mediafire.com/download.php?pgibb205d65596q
通过在下部
TextBox
中输入值来设置RowDefinition.Height
,并使用GridSplitter
调整RowDefinition.Height
的大小代码>I think the problem is that your source Property
Height
is of type double andRowDefinition.Height
is of typeGridLength
. Use a converter and it'll work TwoWayDoubleGridLengthConverter
Update
Uploaded my sample application here: http://www.mediafire.com/download.php?pgibb205d65596q
Set the
RowDefinition.Height
by entering a value in the lowerTextBox
and resize theRowDefinition.Height
with theGridSplitter