Rajesh Yadav

Rajesh Yadav

  • NA
  • 105
  • 8.3k

Want to create WPF in MVVM pattern

Sep 3 2018 6:32 AM
I want to create a solution where I want to write MVVM program using C# and XAML to perform some simple computations.
 

The MainWindow xaml has an named outer grid View.

The xaml code behind (MainWindow.xaml.cs) may only contain a constructor

which sets the View.DataContext to an instance of a new ViewModel class.

 public partial class MainWindow : Window
{ 
public MainWindow() 
{ 
InitializeComponent(); 

View.DataContext = new ViewModel();
 } 
}

Use xaml and additional code / classes to implement the bindings to implement

the following behavior.

MainWindow user interface contains :

  • two input textboxes A and B (with Width=100 and Height=25).

  • two result textboxes containing : C = A + B, and D = A * B, these update, when A or B change.

MainWindow background color is:

  • LightBlue when mouse cursor enters A inputbox

  • LightGreen when mouse cursor enters B inputbox

  • LightGray all other cases.


 

Answers (1)