mvvm - How can i Create a wpf Datagrid view with dynamically generating combobox columns -


how can create datagrid view dynamically generating combobox (through c#) columns , how can bind data dynamically generated columns (through mvvm). want generate different collection of data each combobox inside automatically generated column.

thanks in advance.

not sure why want add combobox via c#. why not use template column take advantage of mvvm should do. view defined in xaml , content bound via viewmodel data.

<datagridtemplatecolumn header="columnheader">      <datagridtemplatecolumn.celltemplate>            <datatemplate>                  <local:costumcontrolwithcombobox text="{binding path=yourlisttopickfrom}"/>            </datatemplate>      </datagridtemplatecolumn.celltemplate> </datagridtemplatecolumn> 

if pick lists should possibly different row. need rule or parameter how bind matching list. note possible add controls mvvm behavior in templatecolumn (just sake of demonstration) bind combobox list itself.

if still prefer build via c# code check out class documentation of datagridtemplatecolumn can accessed via code. https://msdn.microsoft.com/en-us/library/system.windows.controls.datagridtemplatecolumn(v=vs.110).aspx

hth


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -