<Window x:Class="TestApp.Window1"
xmlns="..."
xmlns:x="...">
<StackPanel>
<TextBlock x:Name=”myTextBlock”/>
</StackPanel>
</Window>
Then we need to register the handler through the AddHandler() method. In this example, we do it from within the OnInitialized() function (overridden for this purpose):
public partial class Window1 : Window
{
…
protected override void OnInitialized( EventArgs e )
{
base.OnInitialized( e );
myTextBlock.AddHandler( MouseDownEvent, new RoutedEventHandler( MouseDownEventHandler ) );
}
protected void MouseDownEventHandler( object sender, RoutedEventArgs e )
{
…
}
…
}
Reference URL : http://www.wpfwiki.com/(X(1)S(uutzc3qlnb2f5g5530wnejqj))/Default.aspx?Page=WPF%20Q14.5&AspxAutoDetectCookieSupport=1
No comments:
Post a Comment