下面放一張效果圖:

那么具體是怎么實作呢:
前端XAML中:
<Image Source="/Images/tips.png" HorizontalAlignment="Left" Width="25" Height="25" MouseEnter="Image_MouseEnter" MouseLeave="Image_MouseLeave" IsHitTestVisible="False"/> <Canvas Margin="0,20,0,0" HorizontalAlignment="Left" x:Name="tipsBqb" Opacity="0"> <Image Source="/Images/bqb.jpg" Height="200" Width="200"/> <TextBlock Text="瞅咩啦靚仔" Foreground="Black" FontSize="40" Margin="0,165,0,0" FontWeight="Bold" /> </Canvas>
講一下前端XAML中的一些標簽屬性:
MouseEnter:滑鼠焦點懸浮事件,
MouseLeave:滑鼠焦點懸浮離開事件,
IsHitTestVisible:是否遮擋下層控制元件,(默認為True,也就是說下層的控制元件你點不到)
Canvas:常用的UI布局標簽,
Opacity:透明度,
Image:可以查看我的上一篇博客:https://www.cnblogs.com/Stay627/p/12179045.html,
后臺代碼:
private void Image_MouseEnter(object sender, MouseEventArgs e) { //漸顯 DoubleAnimation daV = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.5))); this.tipsBqb.BeginAnimation(UIElement.OpacityProperty, daV); } private void Image_MouseLeave(object sender, MouseEventArgs e) { //漸隱 DoubleAnimation daV = new DoubleAnimation(1, 0, new Duration(TimeSpan.FromSeconds(0.5))); this.tipsBqb.BeginAnimation(UIElement.OpacityProperty, daV); }
DouBleAnimation物件:指定一個Double型別的屬性,使其在指定的時間內由起點值到達終點值,從而形成影片效果,(引數1:起始引數,引數2:結束引數,引數3:程序秒數)
BeginAnimation方法:執行影片效果,(引數1:控制元件屬性元素,引數2:影片效果引數物件),
然后我們就可以做許多騷操作了,比如保存后,全屏提示保存成功!(例如Minecraft 1.8的全屏提示文字)
搬運轉發請鏈接注明出處,
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/12396.html
標籤:WPF
