←Select platform

OnSourceChanged Method

Summary

Raises the SourceChanged event.

Syntax

C#
VB
C++
protected virtual void OnSourceChanged( 
   RoutedPropertyChangedEventArgs<ImageSource> e 
) 
  
Protected Overridable Sub OnSourceChanged( _ 
   ByVal e As RoutedPropertyChangedEventArgs(Of ImageSource) _ 
)  
protected: 
virtual void OnSourceChanged(  
   RoutedPropertyChangedEventArgs<ImageSource^>^ e 
)  

Parameters

e
A RoutedPropertyChangedEventArgs that contains the event data.

Remarks

Raising an event invokes the event handler through a delegate.

The OnSourceChanged method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

Notes to Inheritors: When overriding OnSourceChanged in a derived class, be sure to call the base class's OnSourceChanged method so that registered delegates receive the event.

Example

C#
VB
Silverlight C#
Silverlight VB
using Leadtools.Help; 
using Leadtools.Windows.Controls; 
 
private void viewer_SourceChanged(object sender, RoutedEventArgs e) 
{ 
   ImageViewer viewer = sender as ImageViewer; 
   string s = string.Format("SourceChanged Event: {0}", viewer.Source.ToString()); 
   MessageBox.Show(s); 
} 
 
public void BitmapSourceViewer_SourceChanged(ImageViewer viewer) 
{ 
   viewer.SourceChanged += new RoutedPropertyChangedEventHandler<ImageSource>(viewer_SourceChanged); 
   viewer.Source = new BitmapImage(new Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg"))); 
 
   viewer.SourceChanged -= new RoutedPropertyChangedEventHandler<ImageSource>(viewer_SourceChanged); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; 
} 
Imports Leadtools.Windows.Controls 
 
Private Sub viewer_SourceChanged(ByVal sender As Object, ByVal e As RoutedEventArgs) 
   Dim viewer As ImageViewer = TryCast(sender, ImageViewer) 
   Dim s As String = String.Format("SourceChanged Event: {0}", viewer.Source.ToString()) 
   MessageBox.Show(s) 
End Sub 
 
Public Sub BitmapSourceViewer_SourceChanged(ByVal viewer As ImageViewer) 
   AddHandler viewer.SourceChanged, AddressOf viewer_SourceChanged 
   viewer.Source = New BitmapImage(New Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg"))) 
 
   RemoveHandler viewer.SourceChanged, AddressOf viewer_SourceChanged 
End Sub 
 
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; 
 
private void viewer_SourceChanged(object sender, RoutedEventArgs e) 
{ 
   ImageViewer viewer = sender as ImageViewer; 
   string s = string.Format("SourceChanged Event: {0}", viewer.Source.ToString()); 
   MessageBox.Show(s); 
} 
 
public void BitmapSourceViewer_SourceChanged(ImageViewer viewer) 
{ 
   viewer.SourceChanged += new RoutedPropertyChangedEventHandler<ImageSource>(viewer_SourceChanged); 
   viewer.Source = new BitmapImage(new Uri(LeadtoolsExamples.Common.ImagesPath.Path + "cannon.jpg")); 
 
   viewer.SourceChanged -= new RoutedPropertyChangedEventHandler<ImageSource>(viewer_SourceChanged); 
} 
Imports Leadtools 
Imports Leadtools.Windows.Controls 
 
Private Sub viewer_SourceChanged(ByVal sender As Object, ByVal e As RoutedEventArgs) 
   Dim viewer As ImageViewer = TryCast(sender, ImageViewer) 
   Dim s As String = String.Format("SourceChanged Event: {0}", viewer.Source.ToString()) 
   MessageBox.Show(s) 
End Sub 
 
Public Sub BitmapSourceViewer_SourceChanged(ByVal viewer As ImageViewer) 
   AddHandler viewer.SourceChanged, AddressOf viewer_SourceChanged 
   viewer.Source = New BitmapImage(New Uri(LeadtoolsExamples.Common.ImagesPath.Path & "cannon.jpg")) 
 
   RemoveHandler viewer.SourceChanged, AddressOf viewer_SourceChanged 
End Sub 

Requirements

Target Platforms

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Windows.Controls Assembly