2013-06-24 69 views
0

從aspx重定向到silverlight xamlPage我是usiver siverlight應用程序。從aspx重定向到silverlight xaml

我使用的是如下因素代碼 HtmlPage.Window.Navigate(新的URI( 「/視圖/頁/ ActiveTaskPage.xaml」,UriKind.Absolute))

它不工作..

能任何人都可以幫助我...

+0

爲什麼你嘗試重定向xaml文件..只需調用.XAP文件對象..它會顯示.XAML文件內容.. – bgs

回答

0

Silverlight 4中自帶的工具,控制和功能,是impossilbe在ASP.NET中實現。公司已經在構建很酷的Silverlight控件。目前,我正在開發一個網站,我們必須構建一些Silverlight自定義控件,並將這些控件與ASP.NET 4.0應用程序集成。

本文介紹我們如何在ASP.NET應用程序中集成和託管Silverlight控件。

首先讓我們創建一個新的Silverlight項目,並將其中的任何內容放入它;你可以使用我的代碼進行測試。

這裏是我的MainPage.xaml

<UserControl x:Class="SLTestExample.MainPage" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" 
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"> 
    <Grid x:Name="LayoutRoot" Background="White" Margin="-146,-105,-145,-109" Height="500" Width="800"> 
     <sdk:DatePicker Height="23" HorizontalAlignment="Left" Margin="183,159,0,0" Name="datePicker1" VerticalAlignment="Top" Width="120" /> 
     <sdk:Calendar Margin="312,149,200,73" d:LayoutOverrides="Width"/> 
     <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Welcome Raj Kumar" VerticalAlignment="Top" Margin="179,125,0,0" Width="158" Foreground="#FFC82C2C" FontWeight="Bold" FontStyle="Italic" FontSize="13.333"/> 
     <Rectangle Fill="#FF9B9BC2" Height="100" Stroke="Black" VerticalAlignment="Top"/> 
     <Rectangle Fill="#FF83A16B" Height="30" Stroke="Black" VerticalAlignment="Bottom"/> 
     <Rectangle Fill="#FFC2AF9B" HorizontalAlignment="Left" Stroke="Black" Width="175" Margin="0,104,0,34"/> 
     <Rectangle Fill="#FF747370" HorizontalAlignment="Right" Stroke="Black" Width="186" Margin="0,104,0,34"/> 
     <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="This is header" VerticalAlignment="Top" Margin="63,11,0,0" Width="263" FontSize="24" FontWeight="Bold" FontStyle="Italic"/> 
     <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="This is footer" VerticalAlignment="Bottom" Margin="60,0,0,7" Width="263" FontSize="13.333" Foreground="#FFE5EFEF"/> 
     <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="This is left bar" VerticalAlignment="Top" Margin="8,106,0,0" Width="157" FontSize="13.333" Foreground="#FFE5EFEF"/> 
     <TextBlock HorizontalAlignment="Right" TextWrapping="Wrap" Text="This is right bar" VerticalAlignment="Top" Margin="0,106,18,0" Width="157" FontSize="13.333" Foreground="#FFE5EFEF"/> 
    </Grid> 
</UserControl> 

現在只需運行該應用程序看到的結果。和

現在把這段代碼放到.aspx頁面。

<body> 
    <form id="form1" runat="server"> 
    <div id="silverlightControlHost"> 
    <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"> 
      <param name="source" value="ClientBin/SLTestExample.xap"/> 
      <param name="onError" value="onSilverlightError" /> 
      <param name="background" value="white" /> 
      <param name="minRuntimeVersion" value="3.0.40818.0" /> 
      <param name="autoUpgrade" value="true" /> 
      <a href="http://go.microsoft.com/fwlink/?LinkID=149156&;v=3.0.40818.0" style="text-decoration:none"> 
        <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/> 
      </a> 
    </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div> 
    </form> 
</body>