如何在后面的代码中创建ItemsControl ItemTemplate [英] How to create Itemscontrol ItemTemplate in code behind

查看:228
本文介绍了如何在后面的代码中创建ItemsControl ItemTemplate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人可以通过/ example / blog如何动态地创建项目控件的项目模板在代码背后?



我有一个对象这有一个动态数量的属性,我需要改变输出,但我很难入门。



我已经从XAML创建了一些,但从来没有



Vb或C#很好,但C#是首选

解决方案

基本上,您将需要创建一个DataTemplate,并使用FrameworkElementFactory创建布局。在Microsoft论坛上有一个例子。



http://social.msdn.microsoft.com/forums/en-US/wpf/thread/f230804d-fc0f-4321-a61e-69a2c890b28d /


Does anyone have a walk through/example/blog of how I can dynamically create the item template of an items control in the code behind?

I have an object that has a dynamic number of properties and I'm needing to vary the output but I'm having difficulty getting started.

I've created a few from XAML but never done it from the code behind.

Vb or C# is fine, but C# is preferred

解决方案

Basically you would need to create a DataTemplate, and use a FrameworkElementFactory to create the layout. There is an example given on the Microsoft forum.

http://social.msdn.microsoft.com/forums/en-US/wpf/thread/f230804d-fc0f-4321-a61e-69a2c890b28d/

这篇关于如何在后面的代码中创建ItemsControl ItemTemplate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆