我正在使用带有 MVVM 模式的 ComponentOne WPF 控件。
我的 ViewModel 中有以下内容:
public ICommand ClientsEnter
{
get
{
if (this.m_ClientsEnter == null)
{
this.m_ClientsEnter = new DelegateCommand<string>(ClientsLostFocusExecute, ClientsLostFocusCanExecute);
}
return m_ClientsEnter;
}
}
和一个可观察的集合:
public ObservableCollection<Client> Clients
{
get { return m_Clients; }
set
{
m_Clients = value;
RaisePropertyChanged("Clients");
}
}
在 Xaml 中,我添加了一个 ComponentOne 组合框,我可以在其中输入ClientName
或ID
按回车键触发事件以执行ClientsEnter
命令:
<Custom1:C1ComboBox Grid.Row="2" Grid.Column="1" Height="24" Name="cmbClients" HorizontalAlignment="Left" VerticalAlignment="Center"
ItemsSource="{Binding Clients, Mode=OneWay}" SelectedValuePath="ClientID" DisplayMemberPath="NameE" IsEditable="True"
Text="Enter Client Name Or ID" SelectedValue="{Binding Path=Filter.ClientID, Mode=TwoWay}" MinWidth="150" Margin="0,2" Width="189">
<i:Interaction.Triggers>
<ei:KeyTrigger Key="Tab" FiredOn="KeyUp" ActiveOnFocus="True" SourceName="cmbClients">
<i:InvokeCommandAction Command="{Binding ClientsEnter, Mode=OneWay}" CommandParameter="{Binding Text,ElementName=cmbClients}" CommandName="KeyDown"/>
</ei:KeyTrigger>
</i:Interaction.Triggers>
</Custom1:C1ComboBox>
我需要知道为什么它不起作用,在按回车后clientID
消失并且没有任何反应。甚至text="Enter Client Name Or ID"
没有出现!有任何想法吗?