How to bind WPF DataGrid to ObservableCollection

前端 未结 4 1104
情歌与酒
情歌与酒 2020-12-16 23:05

Can you give me a tip how to bind a WPF DataGrid to ObservableCollection. I had seen some posts and didn\'t find a direct answer. There and everywhere intricate problems are

4条回答
  •  星月不相逢
    2020-12-16 23:50

    You should be able to do so by using the ItemsSource property of the grid and referencing your collection (probably located in your view model), like this:

    ItemsSource="{Binding Path=DownloadsCollection}" 
    

    Then add a binding on your columns to show the info (properties) of your MyClass objects in the collection.

    For a more detailed tutorial on how to do it, check this link.

    Edit:

    You can simply try something like this to see if everything works right and then move to custom columns:

    
    

提交回复
热议问题