Simple databinding scenario
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2

Thread: Simple databinding scenario

Threaded View

  1. #1
    Join Date
    Sep 2005
    Cracow, Poland

    Simple databinding scenario

    I`m trying to simulate simple two-way databinding mechanism. I have declared simple class for that purpose:

    public class Car : INotifyPropertyChanged
             string color;
             public string Color
                 get { return color; }
                     color = value;
             public event PropertyChangedEventHandler PropertyChanged;
             void OnPropertyChanged(string propertyName)
                 if (PropertyChanged != null)
                     PropertyChanged(null, new PropertyChangedEventArgs(propertyName));

    I have also created object of that class in Window1.cs file:

    public partial class Window1 : Window
             Car veh = new Car();
             public Window1()
                 this.DataContext = veh;

    I have binded this object`s color property for a textbox:

     <TextBox Canvas.Left="276" Canvas.Top="66" Height="19.277" Width="101">
                     <Binding Path="Color" Mode="TwoWay"></Binding>

    Value in this textbox doesn`t refresh however when property of business object changes. What is wrong?
    Last edited by gstercken; April 17th, 2009 at 11:12 AM. Reason: Added code tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a survey!

HTML5 Development Center