Defines the properties required for an item in an ImageList control.
public interface IImageListItem
Public Interface IImageListItem
public interface class IImageListItem
The IImageListItem interface defines the minimum properties required to for an item class that can be used with the ImageList control. The following classes implement this interface and are implemented by LEADTOOLS:
You can define your own classes that implement IImageListItem and use them with the LEADTOOLS ImageList control. The ImageList control derives from the WPF/Silverlight System.Windows.Controls.ItemsControl class and implements the standard WPF binding using a ObservableCollection<IImageListItem> ItemsSource through the ImageList.ItemsSource property. Using binding, you can easily create a collection of your own image list items and add them to the control through code or markup. The example below shows you how to do that.
When using your own class that implements IImageListItem, the following items properties of the ImageList control will be used:
ImageList.ItemSize (will bind to IImageListItem.Width and IImageListItem.Height)
ImageList.ItemImageSize (will bind to IImageListItem.ImageSize
ImageList.ItemBackground (will bind to IImageListItem.Background
ImageList.ItemForeground (will bind to IImageListItem.Foreground
The following item properties will not be used:
ImageList.ItemSelectedBackground. instead, the default System.Windows.Controls.ListBox selection style will be used
ImageList.ItemSelectedForeground. instead, the default System.Windows.Controls.ListBox selection style will be used
This examples shows how to create your own class that implements IImageListItem and bind a collection of these classes to an ImageList control.
Imports Leadtools.Windows.Controls
Private Class MyImageListItem : Implements IImageListItem
#Region "IImageListItem Members"
Private _background As Brush
Public Property Background() As Brush Implements IImageListItem.Background
Get
Return _background
End Get
Set(ByVal value As Brush)
_background = value
End Set
End Property
Private _foreground As Brush
Public Property Foreground() As Brush Implements IImageListItem.Foreground
Get
Return _foreground
End Get
Set(ByVal value As Brush)
_foreground = value
End Set
End Property
Private _height As Double = 100
Public Property Height() As Double Implements IImageListItem.Height
Get
Return _height
End Get
Set(ByVal value As Double)
_height = value
End Set
End Property
Private _imageSize As Size
Public Property ImageSize() As Size Implements IImageListItem.ImageSize
Get
Return _imageSize
End Get
Set(ByVal value As Size)
_imageSize = value
End Set
End Property
Private _source As ImageSource
Public Property Source() As ImageSource Implements IImageListItem.Source
Get
Return _source
End Get
Set(ByVal value As ImageSource)
_source = value
End Set
End Property
Private _text As String
Public Property Text() As String Implements IImageListItem.Text
Get
Return _text
End Get
Set(ByVal value As String)
_text = value
End Set
End Property
Private _uri As Uri
Public Property Uri() As Uri Implements IImageListItem.Uri
Get
Return _uri
End Get
Set(ByVal value As Uri)
_uri = value
End Set
End Property
Private _width As Double = 100
Public Property Width() As Double Implements IImageListItem.Width
Get
Return _width
End Get
Set(ByVal value As Double)
_width = value
End Set
End Property
#End Region
End Class
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
Dim items As ObservableCollection(Of IImageListItem) = New ObservableCollection(Of IImageListItem)()
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 MyImageListItem = New MyImageListItem()
item.Source = New BitmapImage(New Uri(imageFileName))
item.Text = "item" & index.ToString()
item.Uri = New Uri(imageFileName)
' Add the item to the image list
items.Add(item)
Next i
imageList.ItemsSource = items
' Add the ImageList to the Window.
Content = imageList
End Sub
End Class
Public Sub ImageList_IImageListItem(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 MyImageListItem : IImageListItem
{
#region IImageListItem Members
Brush _background;
public Brush Background
{
get { return _background; }
set { _background = value; }
}
Brush _foreground;
public Brush Foreground
{
get { return _foreground; }
set { _foreground = value; }
}
double _height = 100;
public double Height
{
get { return _height; }
set { _height = value; }
}
Size _imageSize;
public Size ImageSize
{
get { return _imageSize; }
set { _imageSize = value; }
}
ImageSource _source;
public ImageSource Source
{
get { return _source; }
set { _source = value; }
}
string _text;
public string Text
{
get { return _text; }
set { _text = value; }
}
Uri _uri;
public Uri Uri
{
get { return _uri; }
set { _uri = value; }
}
double _width = 100;
public double Width
{
get { return _width; }
set { _width = value; }
}
#endregion
}
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;
ObservableCollection<IImageListItem> items = new ObservableCollection<IImageListItem>();
for (int i = 0; i < 3; i++)
{
// Load the image
int index = i + 1;
string imageFileName = Path.Combine(imagesPath, @"ImageProcessingDemo\Image" + index.ToString() + ".jpg");
MyImageListItem item = new MyImageListItem();
item.Source = new BitmapImage(new Uri(imageFileName));
item.Text = "item" + index.ToString();
item.Uri = new Uri(imageFileName);
// Add the item to the image list
items.Add(item);
}
imageList.ItemsSource = items;
// Add the ImageList to the Window.
Content = imageList;
}
}
public void ImageList_IImageListItem(string title)
{
MyWindow1 window = new MyWindow1(title);
window.ShowDialog();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
using Leadtools.Help;
using Leadtools.Windows.Controls;
class MyImageListItem : IImageListItem
{
#region IImageListItem Members
Brush _background;
public Brush Background
{
get { return _background; }
set { _background = value; }
}
Brush _foreground;
public Brush Foreground
{
get { return _foreground; }
set { _foreground = value; }
}
double _height = 100;
public double Height
{
get { return _height; }
set { _height = value; }
}
Size _imageSize;
public Size ImageSize
{
get { return _imageSize; }
set { _imageSize = value; }
}
ImageSource _source;
public ImageSource Source
{
get { return _source; }
set { _source = value; }
}
string _text;
public string Text
{
get { return _text; }
set { _text = value; }
}
Uri _uri;
public Uri Uri
{
get { return _uri; }
set { _uri = value; }
}
double _width = 100;
public double Width
{
get { return _width; }
set { _width = value; }
}
#endregion
}
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;
ObservableCollection<IImageListItem> items = new ObservableCollection<IImageListItem>();
for (int i = 0; i < 3; i++)
{
// Load the image
int index = i + 1;
string imageFileName = imagesPath + "Image" + index.ToString() + ".jpg";
MyImageListItem item = new MyImageListItem();
item.Source = new BitmapImage(new Uri(imageFileName));
item.Text = "item" + index.ToString();
item.Uri = new Uri(imageFileName);
// Add the item to the image list
items.Add(item);
}
imageList.ItemsSource = items;
// Add the ImageList to the Window.
Content = imageList;
}
}
public void ImageList_IImageListItem(string title)
{
MyWindow1 window = new MyWindow1(title);
window.Show();
}
Imports Leadtools
Imports Leadtools.Windows.Controls
Private Class MyImageListItem : Implements IImageListItem
#Region "IImageListItem Members"
Private _background As Brush
Public Property Background() As Brush Implements IImageListItem.Background
Get
Return _background
End Get
Set(ByVal value As Brush)
_background = value
End Set
End Property
Private _foreground As Brush
Public Property Foreground() As Brush Implements IImageListItem.Foreground
Get
Return _foreground
End Get
Set(ByVal value As Brush)
_foreground = value
End Set
End Property
Private _height As Double = 100
Public Property Height() As Double Implements IImageListItem.Height
Get
Return _height
End Get
Set(ByVal value As Double)
_height = value
End Set
End Property
Private _imageSize As Size
Public Property ImageSize() As Size Implements IImageListItem.ImageSize
Get
Return _imageSize
End Get
Set(ByVal value As Size)
_imageSize = value
End Set
End Property
Private _source As ImageSource
Public Property Source() As ImageSource Implements IImageListItem.Source
Get
Return _source
End Get
Set(ByVal value As ImageSource)
_source = value
End Set
End Property
Private _text As String
Public Property Text() As String Implements IImageListItem.Text
Get
Return _text
End Get
Set(ByVal value As String)
_text = value
End Set
End Property
Private _uri As Uri
Public Property Uri() As Uri Implements IImageListItem.Uri
Get
Return _uri
End Get
Set(ByVal value As Uri)
_uri = value
End Set
End Property
Private _width As Double = 100
Public Property Width() As Double Implements IImageListItem.Width
Get
Return _width
End Get
Set(ByVal value As Double)
_width = value
End Set
End Property
#End Region
End Class
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
Dim items As ObservableCollection(Of IImageListItem) = New ObservableCollection(Of IImageListItem)()
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 MyImageListItem = New MyImageListItem()
item.Source = New BitmapImage(New Uri(imageFileName))
item.Text = "item" & index.ToString()
item.Uri = New Uri(imageFileName)
' Add the item to the image list
items.Add(item)
Next i
imageList.ItemsSource = items
' Add the ImageList to the Window.
Content = imageList
End Sub
End Class
Public Sub ImageList_IImageListItem(ByVal title As String)
Dim window As MyWindow1 = New MyWindow1(title)
window.Show()
End Sub
Products |
Support |
Feedback: IImageListItem Interface - Leadtools.Windows.Controls |
Introduction |
Help Version 19.0.2017.3.22
|
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.