偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

WPF圖標(biāo)特殊效果實(shí)現(xiàn)方法

開(kāi)發(fā) 開(kāi)發(fā)工具
WPF圖標(biāo)實(shí)現(xiàn)的效果可以根據(jù)具體程序編程中不同的需求來(lái)進(jìn)行改變。比如我們這里要向大家介紹的顯示標(biāo)簽效果和模糊效果的方法等。

WPF開(kāi)發(fā)工具的用途主要是體現(xiàn)在各種圖形界面的顯示方面。那么在使用的過(guò)程中,其中有很多技巧值得我們?nèi)ド钊胙芯?。本篇將要?shí)現(xiàn)圖標(biāo)的兩個(gè)效果:1. 顯示圖標(biāo)標(biāo)簽,2. 圖標(biāo)模糊效果。#t#

在上一篇中提到Image沒(méi)有HTML < img>的Title屬性(在MSDN中也沒(méi)找到類(lèi)似的屬性),所以本篇將自行制作一個(gè)標(biāo)簽,它的功能是當(dāng)鼠標(biāo)移動(dòng)到圖標(biāo)上方時(shí)會(huì)顯示該圖標(biāo)的Tag說(shuō)明,并且該WPF圖標(biāo)模糊顯示。

1. 在Home < Image>中加入MouseEnter和MouseLeave事件。

 

  1. < Image Source="image/home.png" 
  2. Width="110" Height="110" 
  3. Tag="My Home"Canvas.Left="30"
    Canvas.Top="20" 
  4. Cursor="Hand"   
  5. MouseEnter="Image_BlurEffect_MouseEnter"   
  6. MouseLeave="Image_BlurEffect_MouseLeave"> 
  7. < /Image> 

 

2. 事件加好了,就要為添加內(nèi)容了。先看Image_BlurEffect_MouseEnter事件:

 

  1. private void Image_BlurEffect_
    MouseEnter(object sender,
    MouseEventArgs e)   
  2. {   
  3. //將sender定義為Image對(duì)象   
  4. Image image = sender as Image;  
  5. //創(chuàng)建模糊BlurEffect對(duì)象   
  6. BlurEffect newBlurEffect = 
    new BlurEffect();  
  7. //設(shè)定模糊效果值Radius   
  8. newBlurEffect.Radius = 5;  
  9. //為Image添加Blur效果   
  10. image.Effect = newBlurEffect;  
  11. //將Image Tag內(nèi)容傳給imageTitle 
    Textblock   
  12. imageTitle.Text = " " + 
    image.Tag.ToString() +" ";  
  13. //將imageTitle的Border設(shè)置為可見(jiàn)   
  14. imageTitleBorder.Visibility = 
    Visibility.Visible;  
  15. //調(diào)整imageTitleBorder的Canvas位置,
    使其在圖標(biāo)下方顯示   
  16. Canvas.SetLeft(imageTitleBorder, 
    Canvas.GetLeft(image)+ image.
    Width / 2 - 15);   
  17. Canvas.SetTop(imageTitleBorder, 125);   
  18. }  
  19. private void Image_BlurEffect_
    MouseLeave(object sender,
    MouseEventArgs e)   
  20. {   
  21. Image image = sender as Image;   
  22. BlurEffect newBlurEffect = 
    new BlurEffect();   
  23. newBlurEffect.Radius = 0;   
  24. image.Effect = newBlurEffect;   
  25. imageTitleBorder.Visibility = 
    Visibility.Collapsed;   

 

可以使用ToolTipService。經(jīng)過(guò)測(cè)試使用ToolTip可以實(shí)現(xiàn)標(biāo)簽的功能(代碼如下),而且也不用預(yù)設(shè)WPF圖標(biāo)顯示效果,但是沒(méi)法通過(guò)Canvas設(shè)定其位置,大家可以都學(xué)習(xí)一下。

 

  1. XAML:  
  2. < Image Source="image/home.png" 
    Width="110" Height="110"   
  3. Tag="My Home" Canvas.Left="30" 
    Canvas.Top="20"   
  4. MouseEnter="Image_BlurEffect_
    MouseEnter"
       
  5. MouseLeave="Image_BlurEffect_
    MouseLeave"
       
  6. Cursor="Hand">   
  7. < Image.ToolTip>   
  8. < TextBlock>My Home< /TextBlock>   
  9. < /Image.ToolTip>   
  10. < /Image> 

 

C#代碼自然就簡(jiǎn)單多了:

 

  1. private void Image_BlurEffect_
    MouseEnter(object sender,
    MouseEventArgs e)   
  2. {   
  3. Image image = sender as Image;   
  4. BlurEffect newBlurEffect = 
    new BlurEffect();   
  5. newBlurEffect.Radius = 5;   
  6. image.Effect = newBlurEffect;   

上面這些方法介紹的就是WPF圖標(biāo)顯示效果的實(shí)現(xiàn)。

責(zé)任編輯:曹凱 來(lái)源: ddvip.com
相關(guān)推薦

2009-12-29 14:26:04

WPF按鈕

2010-09-10 09:57:27

DIV樣式

2010-08-24 14:10:44

div style

2015-07-08 16:19:17

iOSUIVisualEff

2010-08-03 11:29:09

Flex全屏

2010-08-17 10:16:37

DIV樣式

2013-07-05 10:26:40

Android

2017-01-22 17:25:55

Android放大鏡效果源碼分析

2013-06-25 11:21:35

Android開(kāi)發(fā)幻燈片效果Gallery

2009-12-28 15:39:33

WPF滑動(dòng)條

2011-08-10 14:40:23

iPhone動(dòng)畫(huà)

2009-12-29 11:01:46

WPF淡入效果

2017-02-14 17:29:42

Android毛玻璃虛化效果

2009-08-17 17:15:48

C# 進(jìn)度條效果

2022-07-28 14:33:32

webviewweb頁(yè)面

2024-04-24 11:09:12

Android圖標(biāo)

2009-12-28 11:14:29

WPF顯示文本

2009-12-24 13:31:25

WPF UI設(shè)計(jì)

2009-12-28 17:33:19

WPF視頻音頻

2009-12-24 17:57:53

WPF頁(yè)面跳轉(zhuǎn)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)