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.

有帮助吗?

解决方案

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

Example :

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

其他提示

Just call:

TxtBlkMessages.RaiseEvent(new TappedRoutedEventArgs());
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top