Hatem Ahmed Gamil
Hatem Ahmed Gamil

Reputation: 91

Interactions with MVVM wpf

I am working with ComponentOne WPF Controls with MVVM Pattern.

I have the following in my ViewModel:

public ICommand ClientsEnter
{
    get
    {
        if (this.m_ClientsEnter == null)
        {
            this.m_ClientsEnter = new DelegateCommand<string>(ClientsLostFocusExecute, 
ClientsLostFocusCanExecute);
        }
        return m_ClientsEnter;
    }
}

And an observable collection:

public ObservableCollection<Client> Clients
{
    get { return m_Clients; }
    set
    {
        m_Clients = value;
        RaisePropertyChanged("Clients");
    }
}

In Xaml I have Added A ComponentOne Combo Box where I can enter ClientName Or ID and press enter to fire Event to execute ClientsEnter Command:

<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="enter"  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>

I need to know why it doesn't work, after pressing enter the clientID Disappears and nothing happens. Even the text="Enter Client Name Or ID" doesn't appear! Any ideas? note that when i change the key to space it works but it doesnt take the text from combobox,

Upvotes: 1

Views: 653

Answers (1)

Hatem Ahmed Gamil
Hatem Ahmed Gamil

Reputation: 91

After spending 2 days investigating this issue ,i discover that there is a bug in C1Combobox as i replaced it with telerik Comboxbox and add the same trigger without changing anything in xaml except the control and it works fine.

finally,i dont recommend C1 wpf controls

Upvotes: 1

Related Questions