¡¡¡¡ÔÚÕâÆªÎÄÕÂÖÐÎÒÃǽ«¿´µ½ÎÒÃÇÈçºÎ¿ÉÒÔÔ¤ÀÀÍøÒ³£¬¶øÎÞÐèʵ¼Êº½ÐÐÔÚSilverlight 4µ½Ëü¡£
¡¡¡¡
¡¡¡¡Create Silverlight Navigation Application´´½¨Silverlightµ¼º½ÖеÄÓ¦ÓÃ
¡¡¡¡Fire up Visual Studio 2010, and select Silverlight Business Application Project from the templates.Æô¶¯Visual Studio 2010ÖУ¬Ñ¡ÔñSilverlightµÄÉÌÒµÓ¦ÓÃÏîÄ¿µÄÄ£°å¡£ Name the solution as PreviewSample .ÃüÃûPreviewSample½â¾ö°ì·¨¡£
¡¡¡¡
¡¡¡¡The template above will create two sample pages for you.ÉÏÊöÄ£°å½«´´½¨Á½¸öÑùƷΪÄúµÄÍøÒ³¡£ Such as “Home” and “About Us”.È瓼ҔºÍ“¹ØÓÚÎÒÃÇ”¡£
¡¡¡¡We would add a new page as “SlideShow.xaml”.ÎÒÃǽ«ÐÂÔöΪ“SlideShow.xaml”еÄÒ»Ò³¡£
¡¡¡¡
¡¡¡¡Let's add some images to the page for a mock of slide show.ÈÃÎÒÃÇÌí¼ÓÁËһЩģÄâµÄ»ÃµÆÆ¬Í¼ÏñÒ³Ãæ¡£
¡¡¡¡The following image displays the Slideshow.xaml page.ÏÂÃæµÄͼÏñÏÔʾSlideshow.xamlÒ³Ãæ¡£
¡¡¡¡
¡¡¡¡Now that our page is ready, let's add the link to the Application.ÏÖÔÚ£¬ÎÒÃǵÄÒ³ÃæÒÑ×¼±¸¾ÍÐ÷£¬ÈÃÎÒÃÇÌí¼Óµ½Ó¦ÓóÌÐòµÄÁ´½Ó¡£ Open MainPage.xaml and add the link there as follows.´ò¿ªMainPage.xaml²¢Ìí¼ÓÁ´½ÓÓÐÈçÏ¡£
¡¡¡¡
¡¡¡¡Now, we can test the application for the navigation purpose.ÏÖÔÚ£¬ÎÒÃÇ¿ÉÒÔ²âÊԵĺ½º£Ìá³öÉêÇë¡£
¡¡¡¡
¡¡¡¡Now we will add two events such as MouseEnter and MouseLeave to the Hyperlink Buttons in MainPage.xaml.ÏÖÔÚÎÒÃǽ«Ìí¼ÓÁ½¸öÈçµÄMouseEnterºÍMouseLeaveʼþÖÐMainPage.xaml³¬Á´½ÓµÄ°´Å¥¡£
¡¡¡¡
¡¡¡¡As you see in above xaml display, Preview_On and Preview_Off are respective event handlers for MouseEnter and Mouse Leave.ÕýÈçÄã¿´µ½µÄÉÏÃæµÄXAMLÏÔʾ£¬Preview_OnºÍPreview_OffÊÇMouseEnterºÍÊó±êÀ뿪¸÷×ÔµÄʼþ´¦Àí³ÌÐò¡£
¡¡¡¡We would create a Border and a Popup element to display the Preview.ÎÒÃǽ«´´½¨Ò»¸ö±ß¿òºÍµ¯³öÔªËØÏÔʾԤÀÀ¡£
¡¡¡¡
¡¡¡¡Now in Preview_On event, we can write the following code.ÏÖÔÚ£¬ÔÚPreview_OnʼþÖУ¬ÎÒÃÇ¿ÉÒÔ±àдÒÔÏ´úÂë¡£
¡¡¡¡
¡¡¡¡As you see in the above code display, we are sending the position of mouse and the HyperlinkButtons's NavigateUri property as a string to a method “CreatePreview”.ÕýÈçÄãÔÚÉÏÃæµÄ´úÂëÏÔʾÆÁÉÏ¿´µ½£¬ÎÒÃÇÅɳöµÄÊó±êλÖúÍHyperlinkButtonsµÄNavigateUri×÷ΪһÖÖ·½·¨“CreatePreview”×Ö·û´®ÊôÐÔ¡£
¡¡¡¡In CreatePreview method we create a Frame and add that to the Popup and display.ÔÚCreatePreview·½·¨ÖУ¬ÎÒÃÇ´´½¨Ò»¸ö¿ò¼Ü£¬²¢Ìí¼Óµ½µ¯³öʽ´°¿ÚºÍÏÔʾ¡£
¡¡¡¡
¡¡¡¡In the above code display, the Green blocked property is very much required otherwise you would not be able to see the mouse hovered link.ÔÚÉÏÃæµÄ´úÂëÏÔʾ£¬ÂÌ·âËøÊǷdz£ÐèÒªµÄ²Æ²ú£¬·ñÔòÄ㽫ÎÞ·¨¿´µ½Êó±êÅÌÐýÁ´½Ó¡£
¡¡¡¡Let's run the application and see how it would look.ÈÃÎÒÃÇÔËÐÐÓ¦ÓóÌÐò£¬¿´¿´ËüµÄÑù×Ó¡£
¡¡¡¡
¡¡¡¡That's it.¾ÍÊÇÕâÑù¡£ Worked fine, you can add some good designs for the preview.¹¤×÷µÃºÜºÃ£¬Äã¿ÉÒÔÌí¼ÓһЩºÃµÄÉè¼ÆÔ¤ÀÀ¡£ And for the user you can add a checkbox for preview on or off.¶ø¶ÔÓÚÓû§£¬Äã¿ÉÒÔÌí¼Ó»ò¹Ø±ÕÔ¤ÀÀ¸´Ñ¡¿ò¡£
¡¡¡¡Hope this article helps.Ï£ÍûÕâÆªÎÄÕ°ïÖú¡£
±¾ÎÄÀ´×ÔctrlhuhuµÄ²©¿Í£¬ÔÎĵØÖ·:ctrlhuhu/blog/item/7b48002443b8b73cc995594d.html
ÔÚÉϼ¸ÆªSilverlight Navigationµ¼º½¿ò¼Ü½Ì³ÌÖУ¬Ö÷Òª½éÉÜÁËSilverlight Navigationµ¼...
ÔÚSilverlightʵÀý½Ì³Ì - Àí½âNavigationµ¼º½¿ò¼ÜFrameÀà ½éÉÜÁËSilverlight Navigati...
ͨ¹ý¡°Navigationµ¼º½¿ò¼Ü¿ªÆª¡±µÄ½éÉÜ£¬¿ÉÒÔÁ˽⵽Silverlightµ¼º½¿ò¼Ü¿É±»Ó¦ÓÃÓÚ¶à...
ÉÏһƪ½éÉÜÁË10¸ö³£ÓÃExpression BlendÉè¼Æ¿ª·¢¼¼ÇÉ£¬±¾Æª½«¼ÌÐø½éÉÜExpression Blend...
΢ÈíExpression BlendÊÇÒ»¿îÓÅÐãµÄÓû§½çÃæÉè¼Æ¹¤¾ß£¬¸Ã¹¤¾ß¿É±»ÓÃÓÚSilverlight£¬WPF...
Òø¹âÖйúÍøÎª·½±ã´ó¼ÒѧϰSilverlight¼¼Êõ£¬ÌرðÍÆ³öSilverlightÃâ·Ñ¿Õ¼ä·þÎñ¡£¿´µ½ÂÛ...
Copyright © 2009 - 2011 SilverlightChina. Òø¹âÖйú
»¦ICP±¸10206900ºÅ