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
); |
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 Basic | Copy Code |
---|
Private Class MyWindow1 : Inherits Window
Public imageList As ListBox
Public Sub New(ByVal title As String)
title = title
Width = 400
Height = 200
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)
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
If i = 0 Then
item.IsSelected = True
End If
imageList.Items.Add(item)
Next i
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
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Vista, and Windows Server 2003 family
See Also