我想在组合框中显示一些数据类型。数据类型包装在以下类中:
public class TDataTypeBinder: INotifyPropertyChanged
{
private string name;
public string Name
{
get
{
return name ;
}
set
{
name = value;
OnPropertyChanged("Name");
}
}
private DataType datatype;
public DataType Datatype
{
get
{
return datatype;
}
set
{
datatype = value;
OnPropertyChanged("Datatype");
}
}
/// <summary>
/// Initializes a new instance of the <see cref="TDataTypeBinder"/> class.
/// </summary>
/// <param name="valueToSelect">The value to select.</param>
public TDataTypeBinder(string valueToSelect)
{
Name = valueToSelect;
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propName)
{
PropertyChangedEventHandler eh = this.PropertyChanged;
if (null != eh)
{
eh(this, new PropertyChangedEventArgs(propName));
}
}
}
目前我有一个绑定属性:
public CollectionView DatatypesDisplayed
{
get
{
List<TDataTypeBinder> list = new List<TDataTypeBinder>();
list.Add(new TDataTypeBinder("String"));
list.Add(new TDataTypeBinder("Float"));
list.Add(new TDataTypeBinder("Integer"));
myDatatypes = new CollectionView(list);
return myDatatypes;
}
}
通过 WorkflowElement 中的 xaml 连接:
<... WorkflowViewElement ...
<ComboBox Name="gType" ItemsSource="{Binding Path=ModelItem.DatatypesDisplayed }" DisplayMemberPath="Name" Margin="3" MinWidth="150" Height="20" />
我的组合框中没有任何内容gType
。我做错了什么?我是 WPF 和 Workflow 4.0 的新手,所以我认为这对你来说并不难。
谢谢你的建议,埃尔