Search code examples
c#wpfxamlwindows-8textblock

Raise Textblock Tapped event manually


I have TextBlock I have declared it in Xaml with its Tapped event.Now i wanted to raise this event manually from code without actually Tap on it from external input.

 private void TxtBlkMessages_Tapped_1(object sender, TappedRoutedEventArgs e)
 {
  // want to raise it manually
  // some storyboards animation is present in it
 }

I have defined it in xaml like this..

<TextBlock Name="TxtBlkMessages"  Tapped="TxtBlkMessages_Tapped_1" />

More precisely i want to raise it from viewmodel on basis of some condition.


Solution

  • If you want it to raise manually then simply u can call the method

    Example :

    private void CallManually()
    {    
        TxtBlkMessages_Tapped_1(null, null);
    }