Using WPF DataGridComboBoxColumn with MVVM - Binding to Property in ViewModel

前端 未结 3 885
后悔当初
后悔当初 2020-12-06 11:28

I\'m using the excellent MVVM Light Toolkit. My ViewModel exposes:

public const string CourtCodesTypeCourtPropertyName = \"CourtCodesTypeCourt\";
private Li         


        
3条回答
  •  庸人自扰
    2020-12-06 11:42

    Here I have found answer http://cinch.codeplex.com/discussions/239522

    For the DataGridComboBoxColumn you have to create a StaticRecource of the ItemsSource like:

    
    

    and bind it to the DataGridComboBoxColumn with following:

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

    Thats because the DataGridColumns are not a part of the visual tree.

    And if you want to bind on a collection of a item of the DataGrid you have to set the ItemsSource over the two styles:

    
          
         
    

提交回复
热议问题