Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Error in c# code??

Options
  • 26-11-2008 3:41pm
    #1
    Registered Users Posts: 6,521 ✭✭✭


    Im getting an error and not sure why. Im using c# and wpf

    the error im getting is

    'Practice_BindingtoObject.Player' does not implement interface member
    'System.ComponentModel.INotifyPropertyChanged'

    heres my code....

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.ComponentModel;

    namespace Practice_BindingtoObject
    {
    class Player:INotifyPropertyChanged
    {
    public event PropertyChangedEventHandler propertyChanged;
    private string _name;
    private DateTime _dob;
    private string _imageFile;



    public string Name
    {
    get { return _name; }
    set
    {
    if (value != _name)
    {
    _name = value;
    NotifyPropertyChanged("Name");// notifys that the value for the image file has changed
    }
    }

    }

    public string DOB
    {
    get { return _dob; }
    set
    {
    if (value != _dob)
    {
    _dob = value;
    NotifyPropertyChanged("DOB");
    }
    }

    }

    public string Image
    {
    get { return _imageFile; }
    set
    {
    if (value != _imageFile)
    {
    _imageFile = value;
    NotifyPropertyChanged("Image");
    }
    }

    }
    private void NotifyPropertyChanged(String info)
    {
    if (PropertyChanged != null)
    PropertyChanged(this, new PropertyChangedEventArgs(info));
    }

    public Player()//default constructor
    {
    Name = "robbie folwer";
    DOB = "1/01/85";
    Image = "";
    }

    public Player(string name, DateTime dob, string image)//working constructor
    {
    Name = name;
    DOB = dob;
    Image = image;

    }


    }//end class
    }//end namespace


    Any help would be great thanks :confused:


Comments

  • Registered Users Posts: 1,996 ✭✭✭lynchie


    Use
    tags in future to keep the code formatted, easier to read..
    
    Case Sensitivity is your answer.
    
    
    [code]
            public event PropertyChangedEventHandler propertyChanged;
    

    is not the same as
            public event PropertyChangedEventHandler [b]P[/b]ropertyChanged;
    


  • Registered Users Posts: 6,521 ✭✭✭joe123


    Bloody Case sensitivity:rolleyes:

    Thanks thats it sorted.


Advertisement