I\'ve got this UserControl
defined in XAML
and would like to set the ItemsPanelTemplate
dynamically in my code behind class (not in th
You need to create an ItemsPanelTemplate
and set it's VisualTree
to a FrameworkElementFactory (deprecated) which creates the Grid
, or use the XamlReader to parse a XAML-string which specifies the template.
This question contains usage examples of both methods (albeit for a different template property).
An easier method to manipulate the panel at runtime is outlined in this question.