1.mainpage.xaml
1<usercontrol x:class="Silverlightclient.mainpage"2xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3xmlns:x="Http://schemas.microsoft.com/winfx/2006/xaml"4xmlns:navigation="clr-namespace:system.windows.controls;assembly=system.windows.controls.navigation" 5Xmlns:d="http://schemas.microsoft.com/expression/blend/2008"Xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 6mc:ignorable="D"D:designwidth="640"d:designheight="480">7<grid x:name="LayoutRoot">8<StackPanel>9<!--navigation Bar--Ten<stackpanel orientation="Horizontal"Background="WhiteSmoke"> One<button x:name="myhtml"Content="HTML content"Fontsize=" -"/> A<button x:name="Myflash"Content="Flash"Fontsize=" -"/> -<button x:name="mypdf"Content="PDF Document"Fontsize=" -"/> -</StackPanel> the<grid x:name="Container"/> -</StackPanel> -</Grid> -</UserControl>
View Code
2.mainpage.xaml.cs
1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Net;5 usingSystem.Windows;6 usingSystem.Windows.Controls;7 usingSystem.Windows.Documents;8 usingSystem.Windows.Input;9 usingSystem.Windows.Media;Ten usingSystem.Windows.Media.Animation; One usingSystem.Windows.Shapes; A usingDivelements.silverlighttools; - - namespacesilverlightclient the { - Public Partial classMainpage:usercontrol - { - PublicMainPage () + { - InitializeComponent (); + //registering event triggering processing A This. Loaded + =NewRoutedeventhandler (mainpage_loaded); at This. Myhtml.click + =NewRoutedeventhandler (Myhtml_click); - This. Myflash.click + =NewRoutedeventhandler (Myflash_click); - This. Mypdf.click + =NewRoutedeventhandler (Mypdf_click); - } - - voidMainpage_loaded (Objectsender, RoutedEventArgs e) in { -Getrichcontent ("http://cn.bing.com", Urikind.absolute); to } + - voidMypdf_click (Objectsender, RoutedEventArgs e) the { *Getrichcontent ("/test.pdf", urikind.relative); $ }Panax Notoginseng - voidMyflash_click (Objectsender, RoutedEventArgs e) the { +Getrichcontent ("/clock.swf", urikind.relative); A } the + voidMyhtml_click (Objectsender, RoutedEventArgs e) - { $Getrichcontent ("http://cn.bing.com", Urikind.absolute); $ } - - //Get Rich Content the voidGetrichcontent (stringUri,urikind UK) - {Wuyi Container.Children.Clear (); theControlhtmlhost cHTML =Newcontrolhtmlhost (); -Htmlhost hh = cHTML. FindName ("Htmlhost") asHtmlhost; Wuhh. SourceUri =NewUri (URI, UK); - Container.Children.Add (cHTML); About } $ } -}
View Code
3. Add a Divelements.SilverlightTools.dll file
4. Add the appropriate access file to the server