{"id":3662,"date":"2014-03-29T07:43:18","date_gmt":"2014-03-29T07:43:18","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/29\/wpf-dynamic-datatemplate-gridview-celltemplate-is-not-null-but-visualtree-property-is-null-collection-of-common-programming-errors\/"},"modified":"2014-03-29T07:43:18","modified_gmt":"2014-03-29T07:43:18","slug":"wpf-dynamic-datatemplate-gridview-celltemplate-is-not-null-but-visualtree-property-is-null-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/29\/wpf-dynamic-datatemplate-gridview-celltemplate-is-not-null-but-visualtree-property-is-null-collection-of-common-programming-errors\/","title":{"rendered":"WPF Dynamic DataTemplate: GridView CellTemplate is not null but VisualTree property is null-Collection of common programming errors"},"content":{"rendered":"<p>I am trying to set the DataTemplate of my ListView.GridView&#8217;s CellTemplate dynamically at runtime. The problem is when I do this, nothing happens. I checked the CellTemplate and it&#8217;s not null but its VisualTree property is null. Any suggestions?<\/p>\n<pre><code>GridViewColumn gvc = new GridViewColumn\n    {\n        Header = col.Label ?? col.Name,\n        DisplayMemberBinding = binding                        \n    };\n\nDataTemplate cellTemplate = FindDataTemplate(listView, col.CellTemplate);\nif (cellTemplate != null)\n    gvc.CellTemplate = cellTemplate;\n\ngridView.Columns.Add(gvc);\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I am trying to set the DataTemplate of my ListView.GridView&#8217;s CellTemplate dynamically at runtime. The problem is when I do this, nothing happens. I checked the CellTemplate and it&#8217;s not null but its VisualTree property is null. Any suggestions? GridViewColumn gvc = new GridViewColumn { Header = col.Label ?? col.Name, DisplayMemberBinding = binding }; DataTemplate [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3662","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3662","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3662"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3662\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3662"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3662"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3662"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}