我有ComboBox
的代码,可以将SelectedItem
绑定到ViewModel
中的属性:
<dxe:ComboBoxEdit x:Name="luTeacher"
Margin="0,5,0,0"
AutoComplete="True"
ItemsSource="{Binding ddsTeachers.Data}"
SelectedItem="{Binding SelectedTeacher, Mode=TwoWay}"
ValueMember="UserId"
DisplayMember="FullName"/>
但是当我尝试将其复制并在Combobox
中的ControlTemplate
上使用时,它无效:
<dxe:ComboBoxEdit
HorizontalAlignment="Left"
Grid.Column="1"
Grid.Row="0"
Margin="0,0,0,4"
VerticalAlignment="Top"
Width="150"
AutoComplete="True"
ItemsSource="{Binding Path=ddsViewTeacher.Data, Source={StaticResource vm}}"
SelectedItem="{Binding SelectedNewTeacher,
Mode=TwoWay, Source={StaticResource vm}}"
DisplayMember="FullName"
ValueMember="UserId"/>
ItemsSource
有效,但SelectedItem
未更新。有什么想法吗?