Sometimes you need to call a method of a UI element from your view model.
E.g. you may want to call the EditBox.Focus or the Frame.Navigate method.

The model:

public class SimpleViewModel : ViewModel
{
    public SimpleViewModel()
    {
        TextBoxWrapper = new ControlWrapper();
    }

    public ControlWrapper TextBoxWrapper { get; private set; }
    
    public void GotoField()
    {
        TextBoxWrapper.Focus();
    }
}


XAML:

<TextBox  Mvvm:ElementBinder.Wrapper="{Binding TextBoxWrapper}"/>

Last edited Sep 20, 2012 at 4:04 AM by mglukhankov, version 1

Comments

No comments yet.