How to bind collection to WPF:DataGridComboBoxColumn

后端 未结 3 832
無奈伤痛
無奈伤痛 2020-12-17 09:27

I have a simple object like:

class Item
{
  ....

  public String Measure { get; set; }
  public String[] Measures {get; }
}

Which I am try

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-17 10:03

    This is hands down the best solution:

    http://wpfthoughts.blogspot.com/2015/04/cannot-find-governing-frameworkelement.html

    The idea here is that you declare a CollectionViewSource as a static resource and then declaratively bind it to ItemsSource of the DataGridComboBoxColumn.

    Create and bind a static CollectionViewSource:

     
         
     
    

    And then bind your target ItemsSource:

    ItemsSource="{Binding Source={StaticResource Owners}}"
    

提交回复
热议问题