Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

22. WPF Binding > Back to the Boys

Back to the Boys

Way back in Chapter 1 we looked at an application that our chefs need. When Gordon is putting together the dessert menu, he needs to be able to choose an ingredient from a list, and to see how much is on hand and how much is available. It’s time to start building it, or a least a simple version of it.

image

Put on Your Thinking Hat

image

Create a new project, and add the Ingredient class declaration. You can use the C# auto-implementation feature for the properties.



How’d You Do?

image

Did you need to go back and check the syntax? That’s okay; it’s been awhile since we’ve done this. What’s important is that you got it working.

public class Ingredient
{

 public Ingredient(string name, int onHand, int allocated)
  {
   this.Name = name;
   this.OnHand = onHand;
   this.Allocated = allocated;
   this.Available = OnHand - Allocated;
  }

 public string Name {get; set;}

 public string Description {get; set;}

 public int OnHand {get; set;}

 public int Allocated {get; set;}

 public int Available {get; set;}
}


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


 Â