我正在使用WPF NotifyIcon并使用此Balloon
:
<UserControl
x:Class="PacketPlayer.ApplicationBalloon"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
Height="130"
Width="283"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:my="clr-namespace:PacketPlayer.classes"
mc:Ignorable="d"
x:Name="me">
<UserControl.Resources>
<Storyboard
x:Key="FadeInAndOut">
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="grid"
Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="0" />
<SplineDoubleKeyFrame
KeyTime="00:00:01"
Value="0.895" />
<SplineDoubleKeyFrame
KeyTime="00:00:10"
Value="0.895" />
<SplineDoubleKeyFrame
KeyTime="00:00:11.6000000"
Value="0" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</UserControl.Resources>
<UserControl.Triggers>
<EventTrigger
RoutedEvent="tb:TaskbarIcon.BalloonShowing">
<BeginStoryboard
Storyboard="{StaticResource FadeInAndOut}"
x:Name="FadeInAndOut_BeginStoryboard" />
</EventTrigger>
</UserControl.Triggers>
<Grid
x:Name="grid">
<Border
x:Name="border"
CornerRadius="10,10,10,10"
Margin="0,0,5,5">
<Border.Background>
<LinearGradientBrush
EndPoint="0.5,1"
StartPoint="0.5,0">
<GradientStop
Color="#FFEEEEEE"
Offset="1" />
<GradientStop
Color="#FF474E5B"
Offset="0" />
</LinearGradientBrush>
</Border.Background>
<Border.Effect>
<DropShadowEffect />
</Border.Effect>
</Border>
<StackPanel Orientation="Vertical" Margin="10,10,0,0">
<TextBlock
VerticalAlignment="Top"
FontSize="18"
FontWeight="Bold"
TextWrapping="Wrap"
Text="Packet Player still running..."
Foreground="White"
Margin="0,0,0,0"/>
<StackPanel Orientation="Horizontal" Margin="0,0,0,0">
<ProgressBar
Name="progressBar"
Width="180"
BorderBrush="White"
Value="0"
Height="20"
Foreground="Yellow"
Background="Transparent"
HorizontalAlignment="Left"
Margin="0,12,0,0"/>
<TextBlock
Name="tbProgressBarPercent"
Text="0%"
Foreground="White"
FontSize="16"
Margin="7,11,0,0"/>
</StackPanel>
<Label
ContentStringFormat="{}{0:#,0} Packets sent"
HorizontalAlignment="Left"
Foreground="White"
Margin="-5,8,0,0"/>
</StackPanel>
</Grid>
</UserControl>
在Balloon
内部我放简单Progress Bar
并通过代码behond更改它的值。
<ProgressBar
Name="progressBar"
Width="180"
Height="25"
BorderBrush="Black"
Value="24"
Background="Transpare
Foreground="Yellow"/>
progressBar.Value = "33;
我唯一的问题是我可以更改所有Progress Bar
属性,Forecolor
无效。