[]
The C1CoverFlow control can be bound to a collection of items. In this section, you will bind the control to an ObservableCollection of type string. The collection you will bind to will be passed as a data context. This topic assumes you are working in Microsoft Expression Blend and that you have added a C1CoverFlow control to your project.
Complete the following steps:
Select the C1CoverFlow control and set the following properties:
Add images to the project by completing the following steps:
Open the MainPage.xaml code page (either MainPage.xaml.cs or MainPage.xaml.vb).
Place the following code beneath the Initialize() method:
‘ Create the ObservableCollection
Dim bluRayCovers As New System.Collections.ObjectModel.ObservableCollection(Of String)()
bluRayCovers.Add("Images/cover1.jpg")
bluRayCovers.Add("Images/cover2.jpg")
bluRayCovers.Add("Images/cover3.jpg")
bluRayCovers.Add("Images/cover4.jpg")
bluRayCovers.Add("Images/cover5.jpg")
‘ Pass the collection to the control as a data context
Me.DataContext = bluRayCovers
// Create the ObservableCollection
System.Collections.ObjectModel.ObservableCollection<string>bluRayCovers = new System.Collections.ObjectModel.ObservableCollection<string>();
bluRayCovers.Add("Images/cover1.jpg");
bluRayCovers.Add("Images/cover2.jpg");
bluRayCovers.Add("Images/cover3.jpg");
bluRayCovers.Add("Images/cover4.jpg");
bluRayCovers.Add("Images/cover5.jpg");
//Pass the collection to the control as a data context
this.DataContext = bluRayCovers;
Bind the collection to the control by completing the following steps:
Create a DataTemplate with an Image control and then bind the Image control’s Source property to the collection by completing the following steps:
to set the Width property to Auto.
to set the Height property to Auto.Run the project and observe that the images specified in the collection are now C1CoverFlow control items.
This Topic Illustrates the Following:
The following image demonstrates the results of this topic.
