Microsoft Developer Network > Página principal de foros > Windows Presentation Foundation (WPF) > How can you set the DataTemplate dynamically of a ListView's column
Formular una preguntaFormular una pregunta
 

RespondidaHow can you set the DataTemplate dynamically of a ListView's column

  • viernes, 05 de junio de 2009 22:02bennyb Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     Tiene código

    I am trying to set the DataTemplate of my ListView.GridView's CellTemplate dynamically at runtime. The problem is when I do this, nothing happens. I checked the CellTemplate and it's not null but its VisualTree property is null. Any suggestions?

    GridViewColumn gvc = new GridViewColumn
       
    {
           
    Header = col.Label ?? col.Name,
           
    DisplayMemberBinding = binding                        
       
    };

    DataTemplate cellTemplate = FindDataTemplate(listView, col.CellTemplate);
    if (cellTemplate != null)
        gvc
    .CellTemplate = cellTemplate;

    gridView
    .Columns.Add(gvc);
    • Editadobennyb viernes, 05 de junio de 2009 22:02
    •  

Respuestas

Todas las respuestas