Bind to a Dependency Property that is in parent's DataContext

后端 未结 2 1254
遥遥无期
遥遥无期 2021-01-19 20:28

I would like to bind third column to a CollectionBindingTwo property that is within Window\'s DataContext and not inside DataContext of an Items from Coll

2条回答
  •  轮回少年
    2021-01-19 20:32

    That's what the [RelativeSource][1] bindings are for. In this case you should be able to target parent data context by way of the the DataGrid's data context:

    
        
    
    

    An ElementName binding should also work:

    
        
    
    

提交回复
热议问题