Microsoft Developer Network > 포럼 홈 > Windows Presentation Foundation (WPF) > How can you set the DataTemplate dynamically of a ListView's column
질문하기질문하기
 

답변됨How can you set the DataTemplate dynamically of a ListView's column

  • 2009년 6월 5일 금요일 오후 10:02bennyb 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     코드 있음

    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);
    • 편집됨bennyb 2009년 6월 5일 금요일 오후 10:02
    •  

답변

모든 응답