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





This member is available in the WPF Express Edition. See the LEADTOOLS products page for full details on more WPF features available with LEADTOOLS toolkits.

Occurs when the value of the SizeMode property changes.

Syntax

Visual Basic (Declaration) 
Public Event SizeModeChanged() As RoutedPropertyChangedEventHandler(Of PaintSizeMode)
Visual Basic (Usage)Copy Code
Dim instance As BitmapSourceViewer
Dim handler As RoutedPropertyChangedEventHandler(Of PaintSizeMode)
 
AddHandler instance.SizeModeChanged, handler
C# 
public event RoutedPropertyChangedEventHandler<PaintSizeMode> SizeModeChanged()
Managed Extensions for C++ 
public: __event RoutedPropertyChangedEventHandler<PaintSizeMode> SizeModeChanged();
C++/CLI 
public:
event RoutedPropertyChangedEventHandler<PaintSizeMode> SizeModeChanged();
XAML Attributes Usage 

<object SizeModeChanged=EventHandler<ExceptionRoutedEventArgs>/> ...

Routed Event Information 

Identifier field

SizeModeChangedEvent

Routing strategy

Bubbling

Delegate

EventHandler<(Of <(TEventArgs>)>)

Example

This example uses the SizeModeChanged event to show how the SizeMode has changed.

Visual BasicCopy Code
Private Sub viewer_SizeModeChanged(ByVal sender As Object, ByVal e As RoutedPropertyChangedEventArgs(Of PaintSizeMode))
   Dim viewer As BitmapSourceViewer = CType(IIf(TypeOf sender Is BitmapSourceViewer, sender, Nothing), BitmapSourceViewer)
   Dim s As String = String.Format("SizeModeChanged Event: {0}", viewer.SizeMode.ToString())
   MessageBox.Show(s)
End Sub
Public Sub BitmapSourceViewer_SizeModeChanged(ByVal viewer As BitmapSourceViewer)
   AddHandler viewer.SizeModeChanged, AddressOf viewer_SizeModeChanged

   Select Case viewer.SizeMode
      Case PaintSizeMode.Fit
         viewer.SizeMode = PaintSizeMode.FitAlways

      Case PaintSizeMode.FitAlways
         viewer.SizeMode = PaintSizeMode.FitWidth

      Case PaintSizeMode.FitWidth
         viewer.SizeMode = PaintSizeMode.Normal

      Case PaintSizeMode.Normal
         viewer.SizeMode = PaintSizeMode.Stretch

      Case PaintSizeMode.Stretch
         viewer.SizeMode = PaintSizeMode.Fit
   End Select

   RemoveHandler viewer.SizeModeChanged, AddressOf viewer_SizeModeChanged
End Sub
C#Copy Code
private void viewer_SizeModeChanged(object sender, RoutedEventArgs e) 

   BitmapSourceViewer viewer = sender as BitmapSourceViewer; 
   string s = string.Format("SizeModeChanged Event: {0}", viewer.SizeMode.ToString()); 
   MessageBox.Show(s); 

public void BitmapSourceViewer_SizeModeChanged(BitmapSourceViewer viewer) 

   viewer.SizeModeChanged += new RoutedPropertyChangedEventHandler<PaintSizeMode>(viewer_SizeModeChanged); 
 
   switch(viewer.SizeMode) 
   { 
      case PaintSizeMode.Fit: 
         viewer.SizeMode = PaintSizeMode.FitAlways; 
         break; 
 
      case PaintSizeMode.FitAlways: 
         viewer.SizeMode = PaintSizeMode.FitWidth; 
         break; 
 
      case PaintSizeMode.FitWidth: 
         viewer.SizeMode = PaintSizeMode.Normal; 
         break; 
 
      case PaintSizeMode.Normal: 
         viewer.SizeMode = PaintSizeMode.Stretch; 
         break; 
 
      case PaintSizeMode.Stretch: 
         viewer.SizeMode = PaintSizeMode.Fit; 
         break; 
   } 
 
   viewer.SizeModeChanged -= new RoutedPropertyChangedEventHandler<PaintSizeMode>(viewer_SizeModeChanged); 
}
XAMLCopy Code
<Window x:Class="WPFSamples.BitmapSourceViewer" Height="600" Width="800" Title="SizeModeChanged Sample" 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"> 
  <DockPanel> 
    <Leadtools_Windows_Controls:BitmapSourceViewer Name="theViewer" Source="file:///C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\slave.jpg" DockPanel.Dock="Bottom" HorizontalAlignment="Center" VerticalAlignment="Center" SizeMode="Fit" SizeModeChanged="viewer_SizeModeChanged" /> 
  </DockPanel> 
</Window>

Remarks

This event is raised if the SizeMode property is changed by either a programmatic modification or user interaction.

Requirements

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

See Also