My issue is that I wish to press enter after typing a text in a textbox. When I do, I want this to trigger a specific property in my viewmodel which is defined in my PCL *(this can not be changed)*.

I have seen some examples that almost do the similar thing but they only do standard actions such as clear text in textbox or tab to next control and so on. I want this one to interact with a property of my choice.

HeaderView.xaml

```
<views:MvxWpfView
         xmlns:views="clr-namespace:Cirrious.MvvmCross.Wpf.Views;assembly=Cirrious.MvvmCross.Wpf"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:UI="clr-namespace:ProductCatalog.UserInterface.WPF.Bootstrap"
         x:Class="ProductCatalog.UserInterface.WPF.Views.HeaderView">
<Grid Height="70" Background="#005287">
        <TextBox DataContext="{Binding SearchText}" UI:TextBoxExtension.EnterKey="Search" 
                 Width="120" Height="35" Padding="8" Margin="10" HorizontalAlignment="Right" >
        </TextBox>
</Grid></views:MvxWpfView>

```

HeaderView.xaml.cs

```
public partial class HeaderView : MvxWpfView
{
    public new HeaderViewModel ViewModel
    {
        get { return (HeaderViewModel) base.ViewModel; }
        set { base.ViewModel = value; }
    }

    public HeaderView()
    {
        InitializeComponent();
    }
}

```

HeaderViewModel.cs (In PCL)

```
public class HeaderViewModel : MvxViewModel
{
    private string _searchText;
    public string SearchText
    {
        get { return _searchText; }
        set
        {
            _searchText = value;
            RaisePropertyChanged(() => SearchText);
        }
    }

    public ICommand Search
    {
        get
        {
            return new MvxCommand(() =>
            {
                SearchItems = new List<string> { "Hey", "Hello", "Hola" };
            });
        }
    }

    private IList<string> _searchItems;
    public IList<string> SearchItems
    {
        get { return _searchItems; }
        set { _searchItems = value; RaisePropertyChanged(() => SearchItems); }
    }
}

```

TextBoxExtension.cs

```
public static class TextBoxExtension
{
    public static ICommand GetEnterKey(DependencyObject obj)
    {
        return (ICommand)obj.GetValue(EnterKey);
    }

    public static void SetEnterKey(DependencyObject obj, ICommand value)
    {
        obj.SetValue(EnterKey, value);
    }

    public static readonly DependencyProperty EnterKey = 
        DependencyProperty.RegisterAttached("EnterKey", typeof(ICommand), typeof(TextBoxExtension), new UIPropertyMetadata(EnterKeyPropertyChanged));

    static void EnterKeyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        UIElement element = d as UIElement;
        if (element == null)
        {
            return;
        }

        element.KeyDown += Keydown;
    }

    static void Keydown(object sender, KeyEventArgs e)
    {
        if (!e.Key.Equals(Key.Enter))
        {
            return;
        }

        UIElement element = sender as UIElement;
        if (element != null)
        {
            ICommand command = GetEnterKey(element);
            command.Execute(null);
        }
    }
}

```

Here is what happens, when I use the parameter `Search` into my UI:TextBoxEntension.EnterKey the event is triggered like I want it to, but it can't find my Search property in my ViewModel. When I try using `{Binding Search}` then the event is never triggered. How can I get the event to trigger my Search property in my ViewModel.

Many thanks