Leadtools.Windows.Controls Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.03.25
ImageSize Property
See Also  Example
Leadtools.Windows.Controls Namespace > ImageListItem Class : ImageSize Property





Gets or sets the maximum size of the image of each ImageListItem in the control.

Syntax

Visual Basic (Declaration) 
Public Property ImageSize As Size
Visual Basic (Usage)Copy Code
Dim instance As ImageListItem
Dim value As Size
 
instance.ImageSize = value
 
value = instance.ImageSize
C# 
public Size ImageSize {get; set;}
Managed Extensions for C++ 
public: __property Size get_ImageSize();
public: __property void set_ImageSize( 
   Size value
);
C++/CLI 
public:
property Size ImageSize {
   Size get();
   void set (Size value);
}
XAML Attributes Usage 

<object ImageSize=Size .../>

Dependency Property Information 

Identifier field

ImageSizeProperty

Metadata properties set to true

None

XAML Property Element Usage 

<object> <object.ImageSize> <Size .../> </object.ImageSize> </object>

Return Value

A Size structure that specifies the maximum size of the image of each ImageListItem in this ImageList in pixels.

Example

Visual BasicCopy Code
Private Class MyWindow1 : Inherits Window
   Public imageList As ListBox
   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 ListBox()
      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
      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()
         item.ViewStyle = ImageListViewStyle.Normal
         item.FileName = imageFileName
         item.Text = imageFileName
         item.ShowText = True
         item.Image = New BitmapImage(New Uri(imageFileName))
         item.ImageSize = New Size(120, 120)
         item.Width = 150
         item.Height = 150
         item.SelectedBackground = Brushes.White
         item.SelectedForeground = Brushes.Blue

         ' 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 ImageListItem_ImageSize(ByVal title As String)
   Dim window As MyWindow1 = New MyWindow1(title)
   window.ShowDialog()
End Sub
C#Copy Code
class MyWindow1 : Window 

   public ListBox imageList; 
   public MyWindow1(string title) 
   { 
      Title = title; 
      // Set the size of the window 
      Width = 400; 
      Height = 200; 
 
      // Create a new ImageList control. 
      imageList = new ListBox(); 
      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++) 
      { 
         int index = i + 1; 
         string imageFileName = imagesPath + "Image" + index.ToString() + ".jpg"; 
 
         ImageListItem item = new ImageListItem(); 
         item.ViewStyle = ImageListViewStyle.Normal; 
         item.FileName = imageFileName; 
         item.Text = imageFileName; 
         item.ShowText = true; 
         item.Image = new BitmapImage(new Uri(imageFileName)); 
         item.ImageSize = new Size(120, 120); 
         item.Width = 150; 
         item.Height = 150; 
         item.SelectedBackground = Brushes.White; 
         item.SelectedForeground = Brushes.Blue; 
 
         // 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 ImageListItem_ImageSize(string title) 

   MyWindow1 window = new MyWindow1(title); 
   window.ShowDialog(); 
}

Remarks

The ImageSize specifies the maximum size of the image of each item in the ImageList control. The ImageListItem.Image of each image is drawn into the item surface using the maximum size possible of ItemImageSize while maintaining the aspect ratio of the image. If the ImageListItem.Image of an item is smaller than ImageSize, then no re-sizing is done when the image is drawn. In other words, the ImageList control implements a "Fit if larger" drawing algorithm when the item images are rendered.

When changing any of the item sizes or styles, you should pay special attention to the values you specify, in general, you should setup ItemSize to be large enough to accommodate ImageSize plus room for ShowText If you set theShowText property to true in your calculations.

For more information about item appearance, refer to ImageList Appearance.

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Vista, and Windows Server 2003 family

See Also