Quantcast
Channel: Silverlight 5 forum
Viewing all articles
Browse latest Browse all 1083

Why dynamically changed data not updated on MVVM binding here

$
0
0

I am using Mvvm approach in silverlight. where i try to bind a TextBox like this :

<Gridx:Name="LayoutRoot"Background="White"><Grid.RowDefinitions><RowDefinitionHeight="50"></RowDefinition><RowDefinitionHeight="*"></RowDefinition></Grid.RowDefinitions><TextBlockText="{Binding ViewModelText}"Grid.Row="0"></TextBlock></Grid>

where this xaml.cs class behind this xaml is:

publicpartialclassUIeLementRender:UserControl{publicUIeLementRender(){InitializeComponent();this.DataContext=newViewModel.TabControlStuffViewModel.uiElementRendererViewModel();}}

and viewmodel class is:

publicclass uiElementRendererViewModel:GenericViewModel{privateString viewModelText;publicStringViewModelText{get{return viewModelText;}set{
            viewModelText = value;OnPropertyChanged("ViewModelText");}}public uiElementRendererViewModel(){this.viewModelText ="Hii from UIelemnt  rendering";//this updated but below one is never updated.}public uiElementRendererViewModel(ProgramVersion pv)//This constructor is called dynamically on abutton click from other view model class but it never updates the viewModelText{this.viewModelText ="Hii changed  UIelemnt  rendering";this.OnPropertyChanged("ViewModelText");}}

Now when i run the code it shows me "Hii from UIelemnt rendering"; (which is correct) but when i press a button from another viewmodel class dynamically, i wan to update new the viewModelText to"Hii changed UIelemnt rendering" . Which is not updated even i have done"this.OnPropertyChanged("ViewModelText");" in my second costructor.

How to update this nex text which is obtained dynamically ?


Viewing all articles
Browse latest Browse all 1083

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>