Problems with Interface implementation.


hi all,

   have started silver light. learning silverlight 2 http://silverlight.net/learn/tutorials.aspx.

 in second tutorial facing problem with  interface implementation. tutorial in vb , trying  in c#.

here code

 

public class book : inotifypropertychanged
 {
     private string booktitle;
     private string bookauthor;
   
   
     // implement required event interface
     public event propertychangedeventhandler inotifypropertychanged.propertychanged; // error :  explicit interface implementation of event must use event accessor syntax   
   
     public string title {
         { return booktitle; }
         set {
             booktitle = value;
             notifypropertychanged("title");
         }
     }

     public string author {
         { return bookauthor; }
         set {
             bookauthor = value;
             notifypropertychanged("author");
         }
     }
    
     // factoring out call event
     public void notifypropertychanged(string propertyname)
     {
         if (propertychanged != null) {
             propertychanged(this, new propertychangedeventargs(propertyname));
         }
       
     }
 }

 

thanks

 

use this:

 

public class book : inotifypropertychanged   {       private string booktitle;       private string bookauthor;                   // implement required event interface       public event propertychangedeventhandler propertychanged;              public string title {           get { return booktitle; }           set {               booktitle = value;               notifypropertychanged("title");           }       }         public string author {           get { return bookauthor; }           set {               bookauthor = value;               notifypropertychanged("author");           }       }              // factoring out call event       public void notifypropertychanged(string propertyname)       {           if (propertychanged != null) {               propertychanged(this, new propertychangedeventargs(propertyname));           }                 }   } 

 also want make sure system.componentmodel namespace referenced @ top of class:

using system.componentmodel;



Silverlight  >  Programming Silverlight with .NET – General



Comments

Popular posts from this blog

Conditional formatting a graph vertical axis in SSRS 2012 charts

Register with Power BI failed

SQL server replication error Cannot find the dbo or user defined function........