←Select platform

ImageList Class

Summary

Represents a WPF/Silverlight image list control, which displays a collection of items that can be displayed using one of the ImageListItemStyle styles.

Syntax

C#
VB
C++
public class ImageList : ListBox 
  
Public Class ImageList  
   Inherits System.Windows.Controls.ListBox 
   Implements System.ComponentModel.ISupportInitialize, System.Windows.Controls.Primitives.IContainItemStorage, System.Windows.IFrameworkInputElement, System.Windows.IInputElement, System.Windows.Markup.IAddChild, System.Windows.Markup.IQueryAmbient, System.Windows.Media.Animation.IAnimatable  
public ref class ImageList : public System.Windows.Controls.ListBox, System.ComponentModel.ISupportInitialize, System.Windows.Controls.Primitives.IContainItemStorage, System.Windows.IFrameworkInputElement, System.Windows.IInputElement, System.Windows.Markup.IAddChild, System.Windows.Markup.IQueryAmbient, System.Windows.Media.Animation.IAnimatable   

Remarks

The ImageList control derives from the WPF/Silverlight System.Windows.Controls.ListBox control and lets you display and manipulate a list of images. The ImageList control contains a list of items that can be used to view thumbnails of WPF/Silverlight System.Windows.Media.ImageSource or LEADTOOLS Leadtools.RasterImage objects.

A ImageList control allows you to display a list of items with text and an image. For example, the Windows Explorer in Thumbnails mode is similar in appearance to a ImageList control. The ImageListItem class represents an item within a ImageList control. The items that are displayed in the list can be shown using one of the ImageListItemStyle styles.

ImageList supports single or multiple item selection. The multiple selection feature lets the user select from a list of items in a way similar to a System.Windows.Controls.ListBox control. Additionally, the user can activate selected items to perform a task. For example, you could use a ImageList control to display a list of files that the application can then open and utilize. The user can select the files to open and then double-click them to activate the items and open the files in the application.

ImageList provides a large number of properties that provide flexibility in appearance and behavior. The ItemStyle property allows you to change the way in which items are displayed. Items are added and removed from the ImageList through the ItemsSource property. The ItemsSource property allows you to access the ObservableCollection of the control, which provides methods for manipulating the items in the control. When your control contains a large number of items, it is often easier for the user to see them in a sorted list. You can use the Sort method to sort the items alphabetically.

In addition to the many properties that are available for a ImageList control, You you may want to provide functionality when the user right-clicks an item. To determine the item which is being clicked, you can use the HitTest(point) method. Sometimes you want to display a specific item to the user to view. The EnsureVisible method can be called to ensure that the specific item is in the visible area of the control.

The ImageList control also supports populating the items directly from the pages of a multi-page TIF file or stream through the LoadTiff(stream) method and saving the current items to a multi-page TIF file or stream using the SaveTiff method.

Example

C#
VB
Silverlight C#
Silverlight VB
using Leadtools.Help; 
using Leadtools.Windows.Controls; 
using Leadtools; 
using Leadtools.Codecs; 
 
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.Background = new RadialGradientBrush(Colors.DarkGray, Colors.LightGray); 
 
      imageList.BorderThickness = new Thickness(5, 5, 5, 5); 
 
      // Create three items 
      string imagesPath = LEAD_VARS.ImagesDir; 
 
      for (int i = 0; i < 3; i++) 
      { 
         // Load the image 
         int index = i + 1; 
         string imageFileName = Path.Combine(imagesPath, @"ImageProcessingDemo\Image" + index.ToString() + ".jpg"); 
 
         ImageListItem item = new ImageListItem(); 
         item.Source = new BitmapImage(new Uri(imageFileName)); 
         item.Text = "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(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; 
} 
Imports Leadtools.Windows.Controls 
Imports Leadtools.Codecs 
Imports Leadtools 
 
Private Class MyWindow1 : Inherits Window 
   Public imageList As ImageList 
   Public Sub New(ByVal title As String) 
      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.Background = New RadialGradientBrush(Colors.DarkGray, Colors.LightGray) 
 
      imageList.BorderThickness = New Thickness(5, 5, 5, 5) 
 
      ' Create three items 
      Dim imagesPath As String = LEAD_VARS.ImagesDir 
 
      For i As Integer = 0 To 2 
         ' Load the image 
         Dim index As Integer = i + 1 
         Dim imageFileName As String = Path.Combine(imagesPath, "ImageProcessingDemo\Image" & index.ToString() & ".jpg") 
 
         Dim item As ImageListItem = New ImageListItem() 
         item.Source = New BitmapImage(New Uri(imageFileName)) 
         item.Text = "item" & index.ToString() 
 
         ' Select the first item 
         If i = 0 Then 
            item.IsSelected = True 
         End If 
 
         ' Add the item to the image list 
         imageList.Items.Add(item) 
      Next i 
 
      ' Add the ImageList to the Window. 
      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 
 
Public NotInheritable Class LEAD_VARS 
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" 
End Class 
using Leadtools.Help; 
using Leadtools.Windows.Controls; 
 
class MyWindow1 : ChildWindow 
{ 
   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.Background = new RadialGradientBrush(Colors.DarkGray, Colors.LightGray); 
 
      imageList.BorderThickness = new Thickness(5, 5, 5, 5); 
 
      // Create three items 
      string imagesPath = LeadtoolsExamples.Common.ImagesPath.Path; 
 
      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(); 
         item.Source = new BitmapImage(new Uri(imageFileName)); 
         item.Text = "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.Show(); 
} 
Imports Leadtools.Windows.Controls 
 
Private Class MyWindow1 : Inherits ChildWindow 
   Public imageList As ImageList 
   Public Sub New(ByVal title As String) 
      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.Background = New RadialGradientBrush(Colors.DarkGray, Colors.LightGray) 
 
      imageList.BorderThickness = New Thickness(5, 5, 5, 5) 
 
      ' Create three items 
      Dim imagesPath As String = LeadtoolsExamples.Common.ImagesPath.Path 
 
      For i As Integer = 0 To 2 
         ' Load the image 
         Dim index As Integer = i + 1 
         Dim imageFileName As String = imagesPath & "Image" & index.ToString() & ".jpg" 
 
         Dim item As ImageListItem = New ImageListItem() 
         item.Source = New BitmapImage(New Uri(imageFileName)) 
         item.Text = "item" & index.ToString() 
 
         ' Select the first item 
         If i = 0 Then 
            item.IsSelected = True 
         End If 
 
         ' Add the item to the image list 
         imageList.Items.Add(item) 
      Next i 
 
      ' Add the ImageList to the Window. 
      Content = imageList 
   End Sub 
End Class 
 
Public Sub ImageList_ImageList(ByVal title As String) 
   Dim window As MyWindow1 = New MyWindow1(title) 
   window.Show() 
End Sub 

Requirements

Target Platforms

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Windows.Controls Assembly