如何将列绑定到不同的源 [英] How to bind a column to different source

查看:58
本文介绍了如何将列绑定到不同的源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个绑定到Source的网格,在同一网格中我想将特定列绑定到不同的源。我怎样才能在xaml中实现这一点。

I have a grid which is binded to a Source, in the same grid I want to bind a particular column to a different source. How can I achieve this in xaml.

推荐答案

这可能会因您的具体情况而有很大差异,发布部分代码会有所帮助。

假设你在一个Window中有一个嵌套的DataGrid,你的两个ItemSource都存在于你的Window DataContext中的


你可以在你的DataGridColumn中尝试这样的东西。 br />


This could vary a lot depending on your situation, posting a part of your code would help.
Assuming you have a nested DataGrid inside a Window and both of your ItemSources are present
in your Window DataContext,
You could try something like this inside your DataGridColumn.

Binding="{Binding Path=DataContext.ItemSource.BindingPath, RelativeSource={RelativeSource  AncestorType={x:Type Window}}}" 


这篇关于如何将列绑定到不同的源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆