使用 XAML 中的以下绑定,所选项目不会显示在组合框中(具体来说,不会显示站点的当前类型)。我们正在使用 caliburn 微框架和 DevForce Ideablade。MySite 是一个 Ideablade 实体。
<ComboBox Grid.Column="3" Grid.Row="3"
ItemsSource="{Binding MySiteTypes}"
DisplayMemberPath="description"
SelectedItem="{Binding MySite.SiteType, Mode=TwoWay}"
SelectedValuePath="description"/>
ViewModel 中的代码:
private BindableCollection<SiteType> _mySiteTypes;
public BindableCollection<SiteType> MySiteTypes
{
get { return _mySiteTypes; }
set { _mySiteTypes = value; NotifyOfPropertyChange(() => MySiteTypes); }
}
一旦我使用组合框设置站点类型(类型存在于下拉列表中),它就会正确显示类型并更改数据库中的类型。我错过了什么,为什么它不想第一次显示现有类型?