Abstract
What this chapter covers:
-
How to import resources such as images into a WPF application
-
Understanding the Abstract factory pattern, a common design pattern
-
How to use an Abstract factory pattern to create an ObservableCollection of image
-
How to use an ObservableCollection to create a DataSource
-
Using a DataSource to populate a ComboBox
-
Creating a Data Template that describes to WPF how to display the content of a ComboBox as an Image control and a TextBlock control
-
Using an ImageBrush to set the background of a StackPanel in the Workspace to the SelectedItem of your ComboBox
An ObservableCollection is a collection of data that can be watched so that when the collection changes, when items are added or removed, for example, controls bound to that data are updated automatically. In this chapter, I am going to show you how to create an ObservableCollection of images, or rather the path on the hard drive of where the images are located. You will then make use of that ObservableCollection to populate a ComboBox that will have a DataTemplate that tells the ComboBox to show the image and the path of the image. In order to create an ObservableCollection, you are going to make use of a common design pattern called an Abstract factory pattern. A design pattern is a general repeatable solution to a commonly occurring problem in software design. A design pattern is not code, per se, but rather a template for how to design code to solve problems with many different solutions. Object-oriented design patterns most often show relationships and interactions between classes and objects. Later in this chapter, you are going to create an Abstract factory pattern called an ImageFactory. With that, let’s get started.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Rights and permissions
Copyright information
© 2008 Victor Gaudioso
About this chapter
Cite this chapter
(2008). ObservableCollections and the Data Factory. In: Foundation Expression Blend 2. Apress. https://doi.org/10.1007/978-1-4302-0612-5_9
Download citation
DOI: https://doi.org/10.1007/978-1-4302-0612-5_9
Publisher Name: Apress
Print ISBN: 978-1-59059-976-1
Online ISBN: 978-1-4302-0612-5
eBook Packages: Professional and Applied ComputingProfessional and Applied Computing (R0)Apress Access Books