【问题标题】:Programmatically get the binding Name以编程方式获取绑定名称
【发布时间】:2014-11-06 09:33:00
【问题描述】:

需要在后面的代码中获取绑定对象的名称。

<telerik:RadGridView x:Name="grdCoverContent" AutoGenerateColumns="False" CanUserInsertRows="False" IsSynchronizedWithCurrentItem="True" 
                                            GridLinesVisibility="Horizontal" telerik:StyleManager.Theme="Windows8"   VerticalAlignment="Top"
                                            ShowGroupPanel="False" ItemsSource="{Binding CoverContentCollection, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=True }" 
                                            SelectedItem="{Binding SelectedCoverContent,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged, Source={StaticResource CoverViewModel} }" RowHeight="30" CellValidating="grdCoverContent_CellValidating" >

有什么方法可以将绑定名称设为“CoverContentCollection”

提前致谢。

【问题讨论】:

    标签: c# wpf telerik


    【解决方案1】:

    您需要的实际上是Binding 的Path(实际上是PropertyPathPath 属性)。所以只需像这样获取绑定并访问它的路径:

    var path = grdCoverContent.GetBindingExpression(ItemsControl.ItemsSourceProperty)
                              .ParentBinding.Path.Path;
    

    代码应该在窗口加载完毕后运行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-15
      • 1970-01-01
      • 2015-11-15
      • 2014-01-17
      • 2018-09-20
      • 2019-03-07
      • 2012-03-11
      • 2015-10-06
      相关资源
      最近更新 更多