在Combobox WPF上输入文本时捕获事件IsEditable

时间:2016-01-13 07:12:09

标签: combobox tags

在我的MVF应用程序中使用MVVM建模。 *当Combobox上的输入文本需要时,Combobox从数据库加载ItemSource:   *预期结果:我可以从Comobox捕获TextChange值以从PropertyChanged绑定值继续进行其他处理   *当前结果:输入文本时无法捕获事件更改。

  • XAML

<ComboBox Style="{StaticResource CmbDoor}" IsEditable="True"
                                          SelectedValuePath="DoorSize" DisplayMemberPath="DoorSize" SelectedValue="{Binding DoorSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                          ItemsSource="{Binding Path=DataContext.Doors, RelativeSource={RelativeSource AncestorType={x:Type views:HeatLoadView}}}" />

  • 代码ViewModels: 与视图绑定的属性:

private decimal _doorHeight; private decimal _doorWidth; public string DoorSize { get { return _doorHeight + "x" + _doorWidth; } set { _doorHeight = 0; _doorWidth = 0;

                if (!string.IsNullOrEmpty(value))
                {
                    int idx = value.IndexOf("x");
                    if (idx >= 0)
                    {
                        decimal.TryParse(value.Substring(0, idx), out _doorHeight);
                        decimal.TryParse(value.Substring(idx + 1), out _doorWidth);
                    }
                }
                OnPropChanged("DoorSize");
                if (Room != null)
                {
                    // TO DO"
                }
            }
        }

0 个答案:

没有答案