Saturday 15 June 2013

c# - WPF Data binding Label content -


I am trying to create a simple WPF application using data binding. This code looks okay, but when I am updating my property, my thoughts are not being updated here. My XML is:

  & lt; Window x: class = "calculator. Main window" xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns: x = "http://schemas.microsoft.com/winfx/2006 / Xaml "xmlns: calculator =" clr-namespace: calculator "title =" main window "height =" 350 "width =" 525 "name =" main vandnom "& gt; & Lt; Grid & gt; & Lt; Label name = "mylabel" background = "light gray" fontSize = "17pt" horizontal conference alignment = "true" margin = "10,10,10,0" workspaceElement = "top" height = "40" content = "{binding path = Calculator output, update resource trigger = property switch) "/> & Lt; / Grid & gt; & Lt; / Window & gt;   

Here my code is behind:

  Namespace calculator {public partial class main window (public main window) {DataContext = new CalculatorViewModel (); InitializeComponent (); }}}   

Here is my view-model

  Namespace calculator {public class calculator ViewModel: INotifyPropertyChanged {Private string _calculatorOutput; Private string calculator output {set {_calculatorOutput = value; NotifyPropertyChanged (); }} Private Event PropertyChangedEventHandler PropertyChanged; Protected Virtual Zero NotifyPropertyChanged ([CallerMemberName] string property name = "") {var handler = property chain; If (handler! = Null) handler (this, new property change event event (property name)); }}}   

I can not see what I'm missing ?? O o.

calculatorOptupput has no objection to how the view should be paid? Property should also be public

  public string calculator output {get {return _calculatorOutput; } Set {_calculatorOutput = value; NotifyPropertyChanged (); }}    

No comments:

Post a Comment