ModernButton中不会触发Click事件和MouseDown事件。为什么不呢?

时间:2016-01-11 22:07:23

标签: c# wpf notifyicon modern-ui

我试图将NotifyIcon-WPF和ModernUI for WPF合并到一个新的,简单的WPF应用程序中。这是一种概念验证类型的应用程序。此时我没有使用MVVM;此时的所有内容都是代码隐藏的。

我试图让现代按钮关闭一个有用户控件的窗口,ModernButton在用户控件上。首先我实现了Click事件,但这并没有起作用。接下来我尝试了ModernButton的MouseDown事件,但这也没有用。接下来我在两个事件中设置一个断点,看看它们是否曾被解雇;断点从未被击中。我不明白为什么不。

这是XAML:

<mui:ModernButton EllipseDiameter="17" 
              IconWidth="15" 
              IconHeight="15" 
              x:Name="CloseButton"
              IconData="{StaticResource CancelIconData}" 
              HorizontalAlignment="Right"
              ToolTip="Close toast message"
              MouseDown="CloseButton_MouseDown"
              Click="CloseButton_Click" />

以下是事件背后的相关C#代码:

private void CloseButton_Click(object sender, RoutedEventArgs e)
{
//the tray icon assigned this attached property to simplify access
TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);
taskbarIcon.CloseBalloon();
}

private void CloseButton_MouseDown(object sender, MouseButtonEventArgs e)
{
//the tray icon assigned this attached property to simplify access
TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);
taskbarIcon.CloseBalloon();
}

0 个答案:

没有答案
相关问题