![](/img/trans.png)
[英]How do I go about turning prexisting code that requires specific type parameters to generic type parameters for this example?
[英]How could I go about turning this into a user managed area (if possible)?
为每个此类事物创建一个基类,假设您将其命名为Thing
。
将ViewModel (如果还没有的话)与ObservableCollection < Thing
>一起使用。
然后,在XAML
,使用ItemsControl为每个此类事物定义DataTemplate并绑定到ViewModel
的ObservableCollection
。 (我建议您将WrapPanel
用于ItemsControl
的ItemsPanel
属性)。
而已! 每当您在ViewModel
的ObservableCollection
中添加新的Thing
,它将自动将其添加到UI中!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.