Leadtools.Windows.Controls Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.03.25
SourceChanged Event
See Also  Example
Leadtools.Windows.Controls Namespace > BitmapSourceViewer Class : SourceChanged 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 Source property changes.

Syntax

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

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

Routed Event Information 

Identifier field

SourceChangedEvent

Routing strategy

Bubbling

Delegate

EventHandler<(Of <(TEventArgs>)>)

Example

This example uses the SourceChanged event to show how the Source has changed.

Visual BasicCopy Code
Public Sub viewer_SourceChanged(ByVal sender As Object, ByVal e As RoutedPropertyChangedEventArgs(Of BitmapSource))
   Dim viewer As BitmapSourceViewer = CType(IIf(TypeOf sender Is BitmapSourceViewer, sender, Nothing), BitmapSourceViewer)
   Dim s As String = String.Format("SourceChanged Event: {0}", viewer.Source.ToString())
   MessageBox.Show(s)
End Sub
Public Sub BitmapSourceViewer_SourceChanged(ByVal viewer As BitmapSourceViewer)
   AddHandler viewer.SourceChanged, AddressOf viewer_SourceChanged
   viewer.Source = New BitmapImage(New Uri("C:\program files\LEAD Technologies\LEADTOOLS 15\Images\Image2.jpg"))

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

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

public void BitmapSourceViewer_SourceChanged(BitmapSourceViewer viewer) 

   viewer.SourceChanged += new RoutedPropertyChangedEventHandler<BitmapSource>(viewer_SourceChanged); 
   viewer.Source = new BitmapImage(new Uri(@"C:\program files\LEAD Technologies\LEADTOOLS 15\Images\Image2.jpg")); 
 
   viewer.SourceChanged -= new RoutedPropertyChangedEventHandler<BitmapSource>(viewer_SourceChanged); 
}
XAMLCopy Code
<Window x:Class="WPFSamples.BitmapSourceViewer" Height="600" Width="800" Title="SourceChanged 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" SourceChanged="viewer_SourceChanged" /> 
  </DockPanel> 
</Window>

Remarks

This event is raised if the Source 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