BindingExpression path using IMultiValueConverter in datacolumn

本文解决了WPF应用程序中使用MultiBinding时出现警告的问题。通过调整XAML中的绑定表达式,确保了Position属性能被正确识别,从而消除了警告。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

    • Hello,


      we use MultiBinding in DataColumn, it works fine. But it will have some warning display in output window, is there a way to remove it?


      I attach a simple app to show this issue:


      System.Windows.Data Warning: 40 : BindingExpression path error: 'Position' property not found on 'object' ''RowTypeDescriptor' (HashCode=34837951)'. BindingExpression:Path=Data.Position.X; DataItem='EditGridCellData' (HashCode=32027802); target element is 'EditGridCellData' (HashCode=32027802); target property is 'DisplayMemberBindingValue' (type 'Object')


      Thanks


      Ella



      <dxg:GridColumn Header="Position">
      <dxg:GridColumn.DisplayMemberBinding>
      <MultiBinding Converter="{local:PositionConverter}">
      <Binding Path="Data.Position.X" RelativeSource="{RelativeSource Self}"/>
      <Binding Path="Data.Position.Y" RelativeSource="{RelativeSource Self}"/>
      <Binding Path="Data.Position.Z" RelativeSource="{RelativeSource Self}"/>
      </MultiBinding>
      </dxg:GridColumn.DisplayMemberBinding>
      </dxg:GridColumn>

    1 Solution

    0

    Hi Ella,

    You don't need to specify a source for binding in the DisplayMemberBinding expression. When this binding expression is resolved, the underlying data object is placed in the data context. So, if the underlying data object has the Position property, the binding expression should look like this:

              
              
    [XAML] Open in popup window
    <dxg:GridColumn Header="Position"> <dxg:GridColumn.DisplayMemberBinding> <MultiBinding Converter="{local:PositionConverter}"> <Binding Path="Position.X" /> <Binding Path="Position.Y" /> <Binding Path="Position.Z" /> </MultiBinding> </dxg:GridColumn.DisplayMemberBinding> </dxg:GridColumn>

    Edited by Vito (DevExpress Support), July 05, 2012:

    It appears that there is a problem with resolving binding expressions when MultiBinding is set. We will examine what causes this problem.

    In the meantime, please use the following code to address this problem:

              
              
    [XAML] Open in popup window
    <dxg:GridColumn Header="Position"> <dxg:GridColumn.DisplayMemberBinding> <MultiBinding Converter="{local:PositionConverter}"> <Binding Path="RowData.Row.Position.X" RelativeSource="{RelativeSource Self}"/> <Binding Path="RowData.Row.Position.Y" RelativeSource="{RelativeSource Self}"/> <Binding Path="RowData.Row.Position.Z" RelativeSource="{RelativeSource Self}"/> </MultiBinding> </dxg:GridColumn.DisplayMemberBinding> </dxg:GridColumn>

    I am attaching the modified sample project, in which this approach is used. Please try it on your side and let us know how it goes.

    • ella sun 4 years ago

        I'm afraid this method is not working, and position could not display. the test is based on my attachment, it's a simple project, please try to fix it, thanks

      • Hello Ella,

        It appears that there is a problem with resolving binding expressions when MultiBinding is set. I have updated the answer Ted posted, and we will examine what causes this problem.

        In the meantime, please use the workaround I described in that answer.

      • ella sun 4 years ago

          It solved the problem, Thank you for your help!

        评论
        添加红包

        请填写红包祝福语或标题

        红包个数最小为10个

        红包金额最低5元

        当前余额3.43前往充值 >
        需支付:10.00
        成就一亿技术人!
        领取后你会自动成为博主和红包主的粉丝 规则
        hope_wisdom
        发出的红包
        实付
        使用余额支付
        点击重新获取
        扫码支付
        钱包余额 0

        抵扣说明:

        1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
        2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

        余额充值