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 > Working with Collections

Working with Collections

image

The list of ingredients isn’t all that useful by itself. What we really want the window to do is display the details of whichever item is selected in the ListBox. It’s a UI pattern called MASTER-DETAIL, and it’s wonderfully easy to do in WPF. Just set the magic IsSynchronizedWithCurrentItem property to true. (IsSynchronizedWithCurrentItem is defined by Selector and inherited by all the items controls that support selection, including ListBox.) Any other elements bound to the same collection will automatically display values from the selected item.

image

Put on Your Thinking Hat

image

Set the IsSynchronizedWithCurrentItem property of the ListBox and bind the remaining controls in the StackPanel.



How’d You Do?

image

Here’s the whole window definition (or at least my version of it):


  

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


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint