Sumit Kumawat

Sumit Kumawat

  • NA
  • 454
  • 405.5k

how to bind textblock using MVVM in wpf?

Jan 23 2013 8:57 AM

Hi all

i am creating WPF app which is based on MVVM model.

in my app i am using two different classes which have inherited by same parent class as bellow:

Public class CARVM : Viewmodel

{

//some properties

//Some methods

}

and

Public class BikeVM : Viewmodel

{

//some properties

//Some methods

}

and now i am  assigning class CARVM as a datacontext of my XAML file.

Further process is as below :

1.calling one method of BikeVM from code behind(XAML.cs).

2.In method(BikeVM method) i am assigning a value to parent's class property(i.e  Viewmodel's Property)

3. now i am binding this property to control in XAML class  as below:

  <TextBlock Text="{Binding Test,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>

while debugging i am getting the new value of properety  but in xaml it is not going to bind.

please help me out.

Thanks in advance.


Answers (4)