WPF - example with DataGridComboBoxColumn

前端 未结 2 930
慢半拍i
慢半拍i 2021-02-19 10:18

I have a datagrid with 2 columns. One column contains role information, the other column should have a combo box with a list of available users. The data in the combobox is unre

2条回答
  •  不要未来只要你来
    2021-02-19 10:37

    the columns in the datagrid dont have a datacontext, as they are never added to the visual tree. sound a bit wierd but have a look at vinces blog, its got a good example of the visual layout. once the grid is drawn the cells have a data context and you can set the combo boxes items source in them using normal bindings (not static resources..)

    you can access the combo box items source as such

       
          
            
          
       
    

    have a look here and also here for some code

提交回复
热议问题