【问题标题】:Cannot tyoe in WPF/RadComboBox which is bound to data无法输入绑定到数据的 WPF/RadComboBox
【发布时间】:2013-11-01 12:52:55
【问题描述】:

我在 WPF 窗口上有多个组合框。每个都是从 ViewModel 填充的。我正在尝试实现自动完成。我尝试过使用 WPF 组合框和 Telerik 组合框。我什至无法开始测试我的自动完成功能是否有效,因为我无法输入组合框。我只能使用退格和空格键。我将 IsEditable 设置为 true。我缺少一些非常基本的东西吗?

来自其中一个组合框的我的 xaml

<DockPanel Style="{StaticResource DockPanelStyle}">
                                <Label Content="Model" DockPanel.Dock="Top"/>
                                <telerik:RadComboBox x:Name="cboModel" DockPanel.Dock="Bottom" Width="100"  ItemsSource="{Binding Path=Models}"
                                         ItemTemplate="{StaticResource ComboBoxCustomTemplate}"  IsEditable="True" StaysOpenOnEdit="True"
                                         telerik:TextSearch.TextPath="value"/>
</DockPanel>

上面的 DockPanel 位于网格内的堆栈面板内。

这是我的 ViewModel 中的相关代码

  public void LoadModels()
        {
            try
            {
                List<CommonData.Model> model = factory.GetStaticModels();
                foreach (CommonData.Model m in model)
                {
                    Models.Add(new CommonData.Model()
                    {
                        value = m.value
                    });
                }
            }
            catch (Exception ex)
            {
                //leaving this out
            }
        } 

private List<CommonData.Model> _models = new List<CommonData.Model>();
        public List<CommonData.Model> Models
        {
            get
            {
                return _models;
            }
            set
            {
                _models = value;
                OnPropertyChanged("Models");
            }
        }

最后,这是我的 Model 类(不是 MVVM Model,类的名称是 Model)

[可序列化]

    public class Model
    {
        private string models;
        public string value
        {
            get;
            set;
        }
    }

非常感谢任何帮助/建议。我对 WPF 很陌生,我觉得我错过了一些非常基本的东西,但我花了 3-4 天的大部分时间在这上面,现在变得非常荒谬。

【问题讨论】:

    标签: c# wpf xaml combobox telerik-combobox


    【解决方案1】:

    IsTextSearchEnabled = "True" 用于标准组合框

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-29
      • 2010-10-27
      • 1970-01-01
      • 2019-01-02
      • 1970-01-01
      相关资源
      最近更新 更多