Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Error in c# code??

  • 26-11-2008 03:41PM
    #1
    Registered Users, Registered Users 2 Posts: 6,537 ✭✭✭


    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, Registered Users 2, Paid Member Posts: 2,032 ✭✭✭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, Registered Users 2 Posts: 6,537 ✭✭✭joe123


    Bloody Case sensitivity:rolleyes:

    Thanks thats it sorted.


Advertisement