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