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.
using Leadtools.Help;using Leadtools.Windows.Controls;class MyImageListItem : IImageListItem{#region IImageListItem MembersBrush _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 windowWidth = 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 itemsstring imagesPath = LEAD_VARS.ImagesDir;ObservableCollection<IImageListItem> items = new ObservableCollection<IImageListItem>();for (int i = 0; i < 3; i++){// Load the imageint 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 listitems.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";}
Imports Leadtools.Windows.ControlsPrivate Class MyImageListItem : Implements IImageListItemPrivate _background As BrushPublic Property Background() As Brush Implements IImageListItem.BackgroundGetReturn _backgroundEnd GetSet(ByVal value As Brush)_background = valueEnd SetEnd PropertyPrivate _foreground As BrushPublic Property Foreground() As Brush Implements IImageListItem.ForegroundGetReturn _foregroundEnd GetSet(ByVal value As Brush)_foreground = valueEnd SetEnd PropertyPrivate _height As Double = 100Public Property Height() As Double Implements IImageListItem.HeightGetReturn _heightEnd GetSet(ByVal value As Double)_height = valueEnd SetEnd PropertyPrivate _imageSize As SizePublic Property ImageSize() As Size Implements IImageListItem.ImageSizeGetReturn _imageSizeEnd GetSet(ByVal value As Size)_imageSize = valueEnd SetEnd PropertyPrivate _source As ImageSourcePublic Property Source() As ImageSource Implements IImageListItem.SourceGetReturn _sourceEnd GetSet(ByVal value As ImageSource)_source = valueEnd SetEnd PropertyPrivate _text As StringPublic Property Text() As String Implements IImageListItem.TextGetReturn _textEnd GetSet(ByVal value As String)_text = valueEnd SetEnd PropertyPrivate _uri As UriPublic Property Uri() As Uri Implements IImageListItem.UriGetReturn _uriEnd GetSet(ByVal value As Uri)_uri = valueEnd SetEnd PropertyPrivate _width As Double = 100Public Property Width() As Double Implements IImageListItem.WidthGetReturn _widthEnd GetSet(ByVal value As Double)_width = valueEnd SetEnd PropertyEnd ClassPrivate Class MyWindow1 : Inherits WindowPublic imageList As ImageListPublic Sub New(ByVal title As String)title = title' Set the size of the windowWidth = 400Height = 200' Create a new ImageList control.imageList = New ImageList()imageList.Width = Double.NaNimageList.Height = Double.NaNimageList.Background = New RadialGradientBrush(Colors.DarkGray, Colors.LightGray)imageList.BorderThickness = New Thickness(5, 5, 5, 5)' Create three itemsDim imagesPath As String = LEAD_VARS.ImagesDirDim items As ObservableCollection(Of IImageListItem) = New ObservableCollection(Of IImageListItem)()For i As Integer = 0 To 2' Load the imageDim index As Integer = i + 1Dim 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 listitems.Add(item)Next iimageList.ItemsSource = items' Add the ImageList to the Window.Content = imageListEnd SubEnd ClassPublic Sub ImageList_IImageListItem(ByVal title As String)Dim window As MyWindow1 = New MyWindow1(title)window.ShowDialog()End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
using Leadtools.Help;using Leadtools.Windows.Controls;class MyImageListItem : IImageListItem{#region IImageListItem MembersBrush _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 windowWidth = 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 itemsstring imagesPath = LeadtoolsExamples.Common.ImagesPath.Path;ObservableCollection<IImageListItem> items = new ObservableCollection<IImageListItem>();for (int i = 0; i < 3; i++){// Load the imageint 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 listitems.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 LeadtoolsImports Leadtools.Windows.ControlsPrivate Class MyImageListItem : Implements IImageListItem''' IImageListItem MembersPrivate _background As BrushPublic Property Background() As Brush Implements IImageListItem.BackgroundGetReturn _backgroundEnd GetSet(ByVal value As Brush)_background = valueEnd SetEnd PropertyPrivate _foreground As BrushPublic Property Foreground() As Brush Implements IImageListItem.ForegroundGetReturn _foregroundEnd GetSet(ByVal value As Brush)_foreground = valueEnd SetEnd PropertyPrivate _height As Double = 100Public Property Height() As Double Implements IImageListItem.HeightGetReturn _heightEnd GetSet(ByVal value As Double)_height = valueEnd SetEnd PropertyPrivate _imageSize As SizePublic Property ImageSize() As Size Implements IImageListItem.ImageSizeGetReturn _imageSizeEnd GetSet(ByVal value As Size)_imageSize = valueEnd SetEnd PropertyPrivate _source As ImageSourcePublic Property Source() As ImageSource Implements IImageListItem.SourceGetReturn _sourceEnd GetSet(ByVal value As ImageSource)_source = valueEnd SetEnd PropertyPrivate _text As StringPublic Property Text() As String Implements IImageListItem.TextGetReturn _textEnd GetSet(ByVal value As String)_text = valueEnd SetEnd PropertyPrivate _uri As UriPublic Property Uri() As Uri Implements IImageListItem.UriGetReturn _uriEnd GetSet(ByVal value As Uri)_uri = valueEnd SetEnd PropertyPrivate _width As Double = 100Public Property Width() As Double Implements IImageListItem.WidthGetReturn _widthEnd GetSet(ByVal value As Double)_width = valueEnd SetEnd PropertyEnd ClassPrivate Class MyWindow1 : Inherits ChildWindowPublic imageList As ImageListPublic Sub New(ByVal title As String)title = title' Set the size of the windowWidth = 400Height = 200' Create a new ImageList control.imageList = New ImageList()imageList.Width = Double.NaNimageList.Height = Double.NaNimageList.Background = New RadialGradientBrush(Colors.DarkGray, Colors.LightGray)imageList.BorderThickness = New Thickness(5, 5, 5, 5)' Create three itemsDim imagesPath As String = LeadtoolsExamples.Common.ImagesPath.PathDim items As ObservableCollection(Of IImageListItem) = New ObservableCollection(Of IImageListItem)()For i As Integer = 0 To 2' Load the imageDim index As Integer = i + 1Dim 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 listitems.Add(item)Next iimageList.ItemsSource = items' Add the ImageList to the Window.Content = imageListEnd SubEnd ClassPublic Sub ImageList_IImageListItem(ByVal title As String)Dim window As MyWindow1 = New MyWindow1(title)window.Show()End Sub
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
