-
Notifications
You must be signed in to change notification settings - Fork 255
NotifyIcon
闫驚鏵(Jinhua Yan) edited this page Jul 21, 2023
·
2 revisions
1)Xaml
<wd:NotifyIcon Title="WPFDevelopers" Name="WpfNotifyIcon">
<wd:NotifyIcon.ContextMenu>
<ContextMenu>
<MenuItem Header="托盘消息" Click="SendMessage_Click"/>
<MenuItem Header="闪烁" Name="menuItemTwink" Click="Twink_Click"/>
<MenuItem Header="关于" Click="About_Click">
<MenuItem.Icon>
<Path Data="{StaticResource PathWarning}"
Fill="{DynamicResource PrimaryNormalSolidColorBrush}"
Stretch="Uniform" Height="20" Width="20"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="退出" Click="Quit_Click"/>
</ContextMenu>
</wd:NotifyIcon.ContextMenu>
</wd:NotifyIcon>
- CSharp
private void Quit_Click(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
}
private void About_Click(object sender, RoutedEventArgs e)
{
new AboutWindow().Show();
}
private void SendMessage_Click(object sender, RoutedEventArgs e)
{
NotifyIcon.ShowBalloonTip("Message", " Welcome to WPFDevelopers",NotifyIconInfoType.None);
}
private void Twink_Click(object sender, RoutedEventArgs e)
{
WpfNotifyIcon.IsTwink = !WpfNotifyIcon.IsTwink;
menuItemTwink.IsChecked = WpfNotifyIcon.IsTwink;
}