【发布时间】:2011-11-30 17:49:33
【问题描述】:
我有一个带有绑定到我的 viewModel 属性的 ComboBox 的视图。 一切正常,但我实际上想重用我的视图并且需要 使用给定值更新控件。设置属性不会更新可视 UI 甚至事件被解雇并且一切看起来都很好。
一切正常都接受 ComboBox 可视化 UI。
提示?!
XAML 控件
<telerik:RadComboBox
ItemTemplate="{StaticResource SelectUserComboBoxTemplate}"
SelectedItem="{Binding Path=SelectedUser, Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding Path=C_users}"
telerik:TextSearch.TextPath="displayName"
Name="radComboBox1"
Margin="14,12,0,0"
Height="31"
VerticalAlignment="Top"
HorizontalAlignment="Left"
Width="253"
TextSearchMode="Contains"
IsEditable="True"
OpenDropDownOnFocus="True"
IsFilteringEnabled="True"
>
</telerik:RadComboBox>
设置值的重载构造函数
public TicketControlTabViewModel(ticket t)
{
activeTicket = t;
SelectedUser = customerServiceClient.getUser(t.customer_users.id);
MetaString = t.meta;
Description = t.description;
ActiveId = t.id.ToString();
Selected_priority = t.priority;
SelectedStatus = t.status;
this.RefreshC_users();
this.RefreshSupportDepartments();
this.RefreshSupportUsers();
}
我的 ViewModel 中的属性
private customer_users selectedUser { get; set; }
public customer_users SelectedUser
{
get {
return this.selectedUser;
}
set {
if (value != null){
this.selectedUser = value;
this.UpdateCustomerDepartment(value);
this.OnPropertyChanged("SelectedUser");
SaveTicket();
}
}
}
【问题讨论】:
-
@Bolt 您已编辑,但在标题中留下了该标签?嘘。
-
C_users 是 ObservableCollection 吗?
-
私有 IEnumerable
c_users;公共 IEnumerable C_users { get { return this.c_users; } 设置 { this.c_users = 值; this.OnPropertyChanged("C_users"); } } -
但是控件应该对 SelectedUser 做出反应...... itemsource 工作......我仍然可以选择用户并且他们被选中等等。它只是用预先选择的项目更新实际控件....我认为它是因为控件是时间加载问题....