Represents an image list control, which displays a collection of items that can be displayed using one of the
ImageListViewStyle styles.
Syntax
Visual Basic (Declaration) | |
---|
Public Class ImageList
Inherits ListBox
Implements IGeneratorHost, IElement |
Visual Basic (Usage) | Copy Code |
---|
Dim instance As ImageList
|
C# | |
---|
public class ImageList : ListBox, IGeneratorHost, IElement |
Managed Extensions for C++ | |
---|
public __gc class ImageList : public ListBox, IGeneratorHost, IElement |
C++/CLI | |
---|
public ref class ImageList : public ListBox, IGeneratorHost, IElement |
XAML Object Element Usage | |
---|
<ImageList .../> |
Example
This example creates an instance of an ImageList control and adds it to a form.
Next, three images are loaded to populate the control.
Visual Basic | Copy Code |
---|
Private Class MyWindow1 : Inherits Window
Public imageList As ImageList
Public Sub New(ByVal title As String)
title = title
Width = 400
Height = 200
imageList = New ImageList()
imageList.Width = Double.NaN
imageList.Height = Double.NaN
imageList.Items.SortDescriptions.Clear()
imageList.Background = New RadialGradientBrush(Colors.DarkGray, Colors.LightGray)
imageList.Items.SortDescriptions.Add(New SortDescription("Text", ListSortDirection.Ascending))
imageList.BorderThickness = New Thickness(5, 5, 5, 5)
Dim imagesPath As String = "C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\"
For i As Integer = 0 To 2
Dim index As Integer = i + 1
Dim imageFileName As String = imagesPath & "Image" & index.ToString() & ".jpg"
Dim item As ImageListItem = New ImageListItem(New BitmapImage(New Uri(imageFileName)), "item" & index.ToString())
If i = 0 Then
item.IsSelected = True
End If
imageList.Items.Add(item)
Next i
Content = imageList
End Sub
End Class
Public Sub ImageList_ImageList(ByVal title As String)
Dim window As MyWindow1 = New MyWindow1(title)
window.ShowDialog()
End Sub |
C# | Copy Code |
---|
class MyWindow1 : Window { public ImageList imageList; public MyWindow1(string title) { Title = title; // Set the size of the window Width = 400; Height = 200; // Create a new ImageList control. imageList = new ImageList(); imageList.Width = Double.NaN; imageList.Height = Double.NaN; imageList.Items.SortDescriptions.Clear(); imageList.Background = new RadialGradientBrush(Colors.DarkGray, Colors.LightGray); imageList.Items.SortDescriptions.Add(new SortDescription("Text", ListSortDirection.Ascending)); imageList.BorderThickness = new Thickness(5, 5, 5, 5); // Create three items string imagesPath = @"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\"; for (int i = 0; i < 3; i++) { // Load the image int index = i + 1; string imageFileName = imagesPath + "Image" + index.ToString() + ".jpg"; ImageListItem item = new ImageListItem(new BitmapImage(new Uri(imageFileName)), "item" + index.ToString()); // Select the first item if (i == 0) item.IsSelected = true; // Add the item to the image list imageList.Items.Add(item); } // Add the ImageList to the Window. Content = imageList; } } public void ImageList_ImageList(string title) { MyWindow1 window = new MyWindow1(title); window.ShowDialog(); } |
Remarks
Inheritance Hierarchy
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Vista, and Windows Server 2003 family
See Also