简体   繁体   中英

Bind a WPF data grid to multiple data sources

I have created a data grid in WPF and have 2 lists. I want to bind one column to one list and rest of the columns to another list. Can anyone please tell me how to do this?

Thanks

Basically, You cant. The datagrid is an ItemsControl which has one ItemsSource property.

What i would do is build a view model which is a composite object that contains one of each of the items (from the two lists). then you could bind to a collection of these.

public class CompositeItem{
   public Object ItemFromListOne { get; set; }
   public Object ItemFromListTwo { get; set; }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM