小编Per*_*son的帖子

从后面的代码更新 ComboBox SelectedItem

我有一个带有绑定到我的 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>
Run Code Online (Sandbox Code Playgroud)

设置值的重载构造函数

    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();
    }
Run Code Online (Sandbox Code Playgroud)

我的 ViewModel 中的属性

    private customer_users selectedUser { get; set; }
    public customer_users SelectedUser
    {

        get …
Run Code Online (Sandbox Code Playgroud)

c# wpf mvvm

2
推荐指数
1
解决办法
3143
查看次数

标签 统计

c# ×1

mvvm ×1

wpf ×1