我正在尝试我的手的WPF。我正在尝试将ComboBox与List<MyClass>绑定,其中MyClass是用户定义的类。我想设置ComboBox的SelectedValuePath属性,以便ComboBox项的值表示MyClass的对象。
我尝试将SelectedValuePath属性设置为.和this,但没有成功。有谁能建议我实现这个目标的方法吗?
示例代码:
Class MyClass
{
public int ID {get; set;}
public string Name {get; set;}
}
List<MyClass> lst = ne
在我们的应用程序中,我们有一组非常大的数据集,用作ComboBox列表等的数据字典。这些数据是静态缓存的,由两个变量进行键控,所以我认为编写一个从ComboBox派生的控件并将这两个键公开为DPs是明智的。当这两个键有适当的值时,我会根据对应的数据字典列表自动设置ComboBox的ComboBox。我还自动将构造函数中的SelectedValuePath和DisplayMemberPath分别设置为代码和描述。
下面是数据字典列表中的ItemsSource中的项是如何总是看起来的示例:
public class DataDictionaryItem
{
public string Co
我的视图上有两个不同的组合框。它们都被绑定到两个不同的字典中。我在我的代码中重命名了一些东西。 public A SelectedFirst { get { ... } set { ... } }
public B SelectedSecond { get { ... } set { ... } }
public Dictionary<A, string> First { get; private set; }
public Dictionary<B, string> Second { get; private set; } A是枚举类型。B是一个具有int和str
我在从一个DataContext中访问窗口的DataGrid时遇到了一些问题。
DataGrid绑定到一个IBindingList:
public IBindingList Items{ get; set; }
private void initItems()
{
//ItemFactory is a Linq2SQL Context, Items is the view of availabe Items
this.Items = this.ItemFactory.Items.GetNewBindingList();
}
在我的xaml
我将ObservableCollection绑定到ComboBox,并将DisplayMemberPath设置为名称,在SelectedValuePath的帮助下,我希望实现Device.ObjectId获取Object.Id的值。但是这似乎不起作用,Object.Name仍然是为Device.ObjectId设置的。如何让ComboBox显示名称但设置Id? public class Object
{
public string Id { get; set; }
public string Name { get; set; }
}
ObservableCo
我在ComboBox中定义了一个DataGrid,如下所示。ItemsSource of ComboBox是包含Name和ID属性的自定义类CodePickList的列表。DisplayMemberPath是Name属性,SelectedValuePath是ID属性。SelectedValue绑定到DataGrid ItemsSource上的GLCode属性。(请注意,ItemsSource的DataGrid是一个视图。)ComboBox正确填充,ComboBox选择与GLCode属性的绑定也有效。对于新的数据来说,这一切都很好。问题在于ItemsSource of DataGrid中现有的数
问题是,我在运行时更改了项的集合,无法让combobox更新以显示新项。我想通过xaml实现这一点。
我想为单个组合框解决这个问题,然后作为一个datagridComboBoxColumn或一个包含一个combobox的模板作为数据集来解决这个问题。
我有这样的代码:
public class Member
{
public string PublicID {get; set;}
public string Description {get; set;}
}
public ObservableCollection<Member> ComboBoxSource;
当传递时,我希望将所选值设置为0,在绑定的项目源列表中,选定的值不可用。
有一个名为类别的类,如下所述:
public class Category
{
private long _CategoryID;
public long CategoryID
{
get
{
return _CategoryID;
}
set
{
_CategoryID = value;
}
}
private string _CategoryName;
p