手动提升Textblock Tapped事件

时间:2014-04-16 11:08:17

标签: c# wpf xaml windows-8 textblock

我有 TextBlock 我已在 Xaml 中声明了 Tapped事件。现在我想从代码手动提升此事件而不实际从外部输入点击它。

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

我已经在xaml中定义了这个..

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

更确切地说,我想根据某些条件从viewmodel中提升它。

2 个答案:

答案 0 :(得分:1)

如果你想手动提升那么你可以调用方法

示例:

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

答案 1 :(得分:0)

请致电:

TxtBlkMessages.RaiseEvent(new TappedRoutedEventArgs());
相关问题