PrepAway - Latest Free Exam Questions & Answers

You need to bind the event to a view model method

You are developing a Universal Windows Platform (UWP) app that uses XAML and C#. The app must use the
Model-View-ViewModel (MVVM) pattern.
The user interface (UI) triggers an event.
You need to bind the event to a view model method.
What should you do? interface is used a lot in MVVM applications.

PrepAway - Latest Free Exam Questions & Answers

A.
Create a custom behavior and attach the behavior to the UI element. Bind the behavior’s event trigger to the
command declared in the view model.

B.
Create an attached property of type ICommand. Bind the UI element’s event to the attached property.

C.
Assign the value of the DataContext property to the view model. Use the BindingExression.UpdateSource()
method to update the data source.

D.
Add a strongly-typed view model property to the view. In the code behind file for the view, invoke the view
model method.

Explanation:
Commands are an implementation of the ICommand interface that is part of the .NET Framework. This
https://msdn.microsoft.com/en-us/magazine/dn237302.aspx

2 Comments on “You need to bind the event to a view model method

    1. nexder says:

      MSDN: “In addition, the bound command will be actuated only when the control is clicked (or tapped with a finger), but no other events are supported.”

      Using a EventToCommand Behavior (here a custom behavior) is the right answear.




      0



      0

Leave a Reply