来自2个来源的WPF组合框绑定 [英] WPF combobox binding from 2 source

查看:43
本文介绍了来自2个来源的WPF组合框绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新手。



我有 ObservableCollection< MyClass>类绑定到 ComboBox。



我想绑定到此 ComboBox 也是我的: string DefaultString = Empty ,因为我不能(也不想)将其添加到我的收藏中。 / p>

像这样的东西:



| --------- |



-空



更改后:



| ---- ----- |



-空



-Class1



可以在xaml中完成,就像对一个元素进行两次绑定一样吗?我应该寻找什么?

解决方案


我应该寻找什么?


CompositeCollection 类。



如何:实现CompositeCollection: https://msdn.microsoft.com/ zh-cn / library / ms742405(v = vs.110).aspx



您如何将CollectionContainer绑定到视图模型中的集合?


I'm new to binding.

I have ObservableCollection<MyClass> Classes binded to ComboBox.

I would like to bind to this ComboBox also my: string DefaultString = "Empty" because I cant (and I dont want to) add it to my collection.

Sth like this:

|---------|

-Empmty

And after changes:

|---------|

-Empty

-Class1

It's possible to do it in xaml, like two bindings to one element? What I should be looking for?

解决方案

What I should be looking for?

The CompositeCollection class.

How to: Implement a CompositeCollection: https://msdn.microsoft.com/en-us/library/ms742405(v=vs.110).aspx

How do you bind a CollectionContainer to a collection in a view model?

这篇关于来自2个来源的WPF组合框绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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