English 中文(简体)
何时不要模版WPF ListBox?
原标题:When not to template a WPF ListBox...?

I m 期望代表收集不同但相关的数据类型,使用户有机会编辑这些数据。 我可以这样说,因为每一种类型都不同,因此不出网布。

e.g.
Type1 - properties are From, To, Threshold, Enabled
Type2 - properties are From, ExecutedPercent, Benchmark, Enabled
etc

这些类型相互关联,但不同的是,设计一种与上层类型相匹配的工具时,我的想法是不同的。 当用户选择类型1时,采用清单Box的定制项目表生成国际数据,类型2相同。 因此,我暂时抽出该项目,并改变数据来源。

Questions:
1. Does this sound like a reasonable approach?
2. Does it make sense to item template ListBox?
3. Are there any other controls I should think about templating here? It seems to me that ListBox is about the perfect candidate for any kind of List source when all the items need to be displayed.

预 收

最佳回答

为了处理不同类型的物品,您可使用。 项目TemplateSelector 这将更加清晰地解决森林问题。

如果你不需要在名单箱中选定项目,而且只需要显示项目,那么你就应当使用<代码>。 项目Control而不是ListBox

问题回答

您可以使用一位数据字典,这样,当这一类型被转换成数据来源时,你就不得不确定该片面。





相关问题
WPF convert 2d mouse click into 3d space

I have several geometry meshes in my Viewport3D, these have bounds of (w:1800, h:500, d:25). When a user clicks in the middle of the mesh, I want the Point3D of (900, 500, 25)... How can I achieve ...

Editing a xaml icons or images

Is it possible to edit a xaml icons or images in the expression design or using other tools? Is it possible to import a xaml images (that e.g you have exported) in the expression designer for editing?...

WPF: writing smoke tests using ViewModels

I am considering to write smoke tests for our WPF application. The question that I am faced is: should we use UI automation( or some other technology that creates a UI script), or is it good enough to ...

WPF - MVVM - NHibernate Validation

Im facing a bit of an issue when trying to validate a decimal property on domain object which is bound to a textbox on the view through the viewmodel. I am using NHibernate to decorate my property on ...

How do WPF Markup Extensions raise compile errors?

Certain markup extensions raise compile errors. For example StaticExtension (x:Static) raises a compile error if the referenced class cannot be found. Anyone know the mechanism for this? Is it baked ...

WPF design-time context menu

I am trying to create a custom wpf control, I m wondering how I can add some design-time features. I ve googled and can t seem to get to my goal. So here s my simple question, how can I add an entry ...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签