xaml中:
<ComboBox SelectedValue="{Binding DepId}" SelectedValuePath="Id" DisplayMemberPath="Name"/>
后台代码: comboBox1.ItemsSource = DepartmentDAL.GetAll();
这样是成功的!但是<ComboBox />不在xaml中绑定,完全在后台的话:
comboBox1.ItemsSource = DepartmentDAL.GetAll();
comboBox1.SelectedValue = "DepId";
comboBox1.DisplayMemberPath = "Name";
comboBox1.SelectedValuePath = "Id";
就会出现FormatException
GUID 应包含带 4 个短划线的 32 位数(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)。错误!!
求解?????
bindingC#
<ComboBox SelectedValue="{Binding DepId}" SelectedValuePath="Id" DisplayMemberPath="Name"/>
后台代码: comboBox1.ItemsSource = DepartmentDAL.GetAll();
这样是成功的!但是<ComboBox />不在xaml中绑定,完全在后台的话:
comboBox1.ItemsSource = DepartmentDAL.GetAll();
comboBox1.SelectedValue = "DepId";
comboBox1.DisplayMemberPath = "Name";
comboBox1.SelectedValuePath = "Id";
就会出现FormatException
GUID 应包含带 4 个短划线的 32 位数(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)。错误!!
求解?????
bindingC#
comboBox1.DisplayMemberPath = "Name";
comboBox1.SelectedValuePath = "Id";
comboBox1.ItemsSource = DepartmentDAL.GetAll();
交换下位置