←Select platform

ImageSize Property (ImageListItem)

Summary

Gets or sets the image size in pixels. This is a dependency property.

Syntax

C#
VB
C++
[CategoryAttribute("Appearance")] 
[DescriptionAttribute("Size of each item image in pixels.")] 
public Size ImageSize {get; set;} 
<CategoryAttribute("Appearance")> 
<DescriptionAttribute("Size of each item image in pixels.")> 
Public Property ImageSize As Size 
[CategoryAttribute("Appearance")] 
[DescriptionAttribute("Size of each item image in pixels.")] 
public: 
property Size ImageSize { 
   Size get(); 
   void set (    Size ); 
} 

Property Value

The image size in pixels. Default value is 48,48.

Remarks

The image size is the area inside the item where the image (in Source) will be drawn. This must be equal to or less than Width and Height.

The image will be drawn inside the rectangle define by ImageSize and centered inside Width and Height.

Example

C#
VB
Silverlight C#
Silverlight VB
Imports Leadtools.Windows.Controls 
 
Private Class MyWindow1 : Inherits Window 
    Private theViewer As ImageViewer 
    Public Sub New() 
        ' Create the  viewer 
        theViewer = New ImageViewer() 
        ' Create Dock Panel 
 
        Dim panel As DockPanel = New DockPanel() 
        Content = panel 
 
        DockPanel.SetDock(theViewer, Dock.Bottom) 
 
        theViewer.HorizontalAlignment = HorizontalAlignment.Center 
        theViewer.VerticalAlignment = VerticalAlignment.Bottom 
        theViewer.ImageHorizontalAlignment = HorizontalAlignment.Left 
        theViewer.ImageVerticalAlignment = VerticalAlignment.Top 
        theViewer.UseDpi = True 
        theViewer.ScreenDpiX = 96 
        theViewer.ScreenDpiY = 96 
 
        panel.Children.Add(theViewer) 
 
        ' load an image into the viewer 
        theViewer.Source = New BitmapImage(New Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg"))) 
 
        Title = String.Format("Size mode = {0}, double click to change", theViewer.SizeMode) 
 
        AddHandler theViewer.MouseDoubleClick, AddressOf theViewer_MouseDoubleClick 
    End Sub 
 
    Private Sub theViewer_MouseDoubleClick(ByVal sender As Object, ByVal e As MouseButtonEventArgs) 
        Select Case theViewer.SizeMode 
            Case SizeMode.Normal 
                theViewer.SizeMode = SizeMode.Stretch 
 
            Case SizeMode.Stretch 
                theViewer.SizeMode = SizeMode.Fit 
 
            Case SizeMode.Fit 
                theViewer.SizeMode = SizeMode.FitAlways 
 
            Case SizeMode.FitAlways 
                theViewer.SizeMode = SizeMode.FitWidth 
 
            Case SizeMode.FitWidth 
                theViewer.SizeMode = SizeMode.Normal 
        End Select 
 
        Title = String.Format("Size mode = {0}, double click to change", theViewer.SizeMode) 
 
    End Sub 
End Class 
 
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 : Window 
{ 
   ImageViewer theViewer; 
   public MyWindow1() 
   { 
      // Create the  viewer 
      theViewer = new ImageViewer(); 
      // Create Dock Panel 
 
      DockPanel panel = new DockPanel(); 
      Content = panel; 
 
      DockPanel.SetDock(theViewer, Dock.Bottom); 
 
      theViewer.HorizontalAlignment= HorizontalAlignment.Center; 
      theViewer.VerticalAlignment= VerticalAlignment.Bottom; 
      theViewer.ImageHorizontalAlignment = HorizontalAlignment.Left; 
      theViewer.ImageVerticalAlignment = VerticalAlignment.Top; 
      theViewer.UseDpi = true; 
      theViewer.ScreenDpiX = 96; 
      theViewer.ScreenDpiY = 96; 
 
      panel.Children.Add(theViewer); 
 
      // load an image into the viewer 
      theViewer.Source = new BitmapImage(new Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg"))); 
 
      Title = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode); 
 
      theViewer.MouseDoubleClick += new MouseButtonEventHandler(theViewer_MouseDoubleClick); 
   } 
 
   void theViewer_MouseDoubleClick(object sender, MouseButtonEventArgs e) 
   { 
      switch(theViewer.SizeMode) 
      { 
         case SizeMode.Normal: 
            theViewer.SizeMode = SizeMode.Stretch; 
            break; 
 
         case SizeMode.Stretch: 
            theViewer.SizeMode = SizeMode.Fit; 
            break; 
 
         case SizeMode.Fit: 
            theViewer.SizeMode = SizeMode.FitAlways; 
            break; 
 
         case SizeMode.FitAlways: 
            theViewer.SizeMode = SizeMode.FitWidth; 
            break; 
 
         case SizeMode.FitWidth: 
            theViewer.SizeMode = SizeMode.Normal; 
            break; 
      } 
 
      Title = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode); 
 
   } 
} 
 
static class LEAD_VARS 
{ 
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; 
} 
using Leadtools.Help; 
using Leadtools.Windows.Controls; 
 
class MyWindow1 : ChildWindow 
{ 
   ImageViewer theViewer; 
   public MyWindow1() 
   { 
      // Create the  viewer 
      theViewer = new ImageViewer(); 
      // Create Dock Panel 
 
      StackPanel panel = new StackPanel(); 
      Content = panel; 
 
      theViewer.HorizontalAlignment= HorizontalAlignment.Center; 
      theViewer.VerticalAlignment= VerticalAlignment.Bottom; 
      theViewer.ImageHorizontalAlignment = HorizontalAlignment.Left; 
      theViewer.ImageVerticalAlignment = VerticalAlignment.Top; 
      theViewer.UseDpi = true; 
      theViewer.ScreenDpiX = 96; 
      theViewer.ScreenDpiY = 96; 
 
      panel.Children.Add(theViewer); 
 
      // load an image into the viewer 
      theViewer.Source = new BitmapImage(new Uri(LeadtoolsExamples.Common.ImagesPath.Path + "cannon.jpg")); 
 
      Title = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode); 
 
      theViewer.MouseLeftButtonDown += new MouseButtonEventHandler(theViewer_MouseLeftButtonDown); 
   } 
 
   void theViewer_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) 
   { 
      switch (theViewer.SizeMode) 
      { 
         case SizeMode.Normal: 
            theViewer.SizeMode = SizeMode.Stretch; 
            break; 
 
         case SizeMode.Stretch: 
            theViewer.SizeMode = SizeMode.Fit; 
            break; 
 
         case SizeMode.Fit: 
            theViewer.SizeMode = SizeMode.FitAlways; 
            break; 
 
         case SizeMode.FitAlways: 
            theViewer.SizeMode = SizeMode.FitWidth; 
            break; 
 
         case SizeMode.FitWidth: 
            theViewer.SizeMode = SizeMode.Normal; 
            break; 
      } 
 
      Title = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode); 
   } 
} 
Imports Leadtools 
Imports Leadtools.Windows.Controls 
 
Private Class MyWindow1 : Inherits ChildWindow 
   Private theViewer As ImageViewer 
   Public Sub New() 
      ' Create the  viewer 
      theViewer = New ImageViewer() 
      ' Create Dock Panel 
 
      Dim panel As StackPanel = New StackPanel() 
      Content = panel 
 
      theViewer.HorizontalAlignment = HorizontalAlignment.Center 
      theViewer.VerticalAlignment = VerticalAlignment.Bottom 
      theViewer.ImageHorizontalAlignment = HorizontalAlignment.Left 
      theViewer.ImageVerticalAlignment = VerticalAlignment.Top 
      theViewer.UseDpi = True 
      theViewer.ScreenDpiX = 96 
      theViewer.ScreenDpiY = 96 
 
      panel.Children.Add(theViewer) 
 
      ' load an image into the viewer 
      theViewer.Source = New BitmapImage(New Uri(LeadtoolsExamples.Common.ImagesPath.Path & "cannon.jpg")) 
 
      Title = String.Format("Size mode = {0}, double click to change", theViewer.SizeMode) 
 
      AddHandler theViewer.MouseLeftButtonDown, AddressOf theViewer_MouseLeftButtonDown 
   End Sub 
 
   Private Sub theViewer_MouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs) 
      Select Case theViewer.SizeMode 
         Case SizeMode.Normal 
            theViewer.SizeMode = SizeMode.Stretch 
 
         Case SizeMode.Stretch 
            theViewer.SizeMode = SizeMode.Fit 
 
         Case SizeMode.Fit 
            theViewer.SizeMode = SizeMode.FitAlways 
 
         Case SizeMode.FitAlways 
            theViewer.SizeMode = SizeMode.FitWidth 
 
         Case SizeMode.FitWidth 
            theViewer.SizeMode = SizeMode.Normal 
      End Select 
 
      Title = String.Format("Size mode = {0}, double click to change", theViewer.SizeMode) 
   End Sub 
End Class 
<Window x:Class="WPFSamples.ImageViewer" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:Leadtools_Windows_Controls="clr-namespace:Leadtools.Windows.Controls;assembly=Leadtools.Windows.Controls" 
    Height="600" Width="800"> 
  <DockPanel> 
    <Leadtools_Windows_Controls:ImageViewer 
                Name="theViewer" 
                Source="file:///c:\users\Public\Documents\LEADTOOLS Images\cannon.jpg" 
                DockPanel.Dock= "Bottom" 
                HorizontalAlignment="Center" VerticalAlignment="Bottom" 
                UseDpi="false" 
                MouseDoubleClick="theViewer_MouseDoubleClick"/> 
  </DockPanel> 
  <Window.Title> 
    "Size mode =Normal, double click to change" 
  </Window.Title> 
</Window> 

Requirements

Target Platforms

Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
Leadtools.Windows.Controls Assembly
Click or drag to resize