c# - WPF 行高绑定(bind)在用户使用 GridSplitter 后停止工作

标签 c# wpf binding grid height

我有一个四行的网格:

<Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>                
            <RowDefinition Height="{Binding DocumentsHeight}"/>
            <RowDefinition Height="Auto"/> - GRIDSPLITTER
            <RowDefinition Height="{Binding ApprovedDocumentsHeight}" /> 
</Grid.RowDefinitions>

行的动态大小调整工作正常,高度绑定(bind)到值如“5*”的字符串。但是当用户使用 GridSplitter 时,绑定(bind)停止工作,当我想更改行的大小时,在下一次通知之后不会调用 getter。有人知道问题出在哪里吗?

感谢您的帮助。

最佳答案

如果您绑定(bind)到 GridLength 以外的任何东西,绑定(bind)将会中断。 您可以像这样绑定(bind)到 GridLength 属性...

   private double documentsHeight = 100;

   public GridLength DocumentsHeight
    {
        get { return this.GridLength(this.documentsHeight); }
        set { this.documentsHeight = value.Value; }
    }

此外,您还需要在绑定(bind)上设置 Mode=TwoWay。

关于c# - WPF 行高绑定(bind)在用户使用 GridSplitter 后停止工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20124175/

相关文章:

javascript - 取消输入时提交

c# - 是否可以指定代码契约以确保该方法不会更改对象的状态

c# - WPF DataGrid 中类似 Excel 的选择矩形

c# - wpf Storyboard死亡

wpf - 使用ViewModelLocator时如何标记viewmodel?

wpf - 如何使格式化的 TextBlock 宽度数据绑定(bind)可本地化?

c# - Wpf 实时数据绑定(bind)到 ListView

c# - Entity Framework 4 - 包含自相关表

c# - 上传 HttpPostedFileBase 文件和一些参数

c# - 在资源中绑定(bind)数据上下文