我尝试学习silverlight,但我不明白为什么silverproject无法在SilverlightTest页面上显示
<UserControl x:Class="SilverlightApplication1.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Canvas x:Name="cnvLayoutRoot" Background="White">
<TextBlock x:Name="tblText" Canvas.Top="20" Canvas.Left="30" Text="Not clicked yet."></TextBlock>
<Button x:Name="btnTest" Canvas.Top="60" Canvas.Left="30" Click="btnTest_Click" Content="Click me!"></Button>
</Canvas>
</UserControl>
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls"
TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>SilverlightApplication1</title>
<style type="text/css">
html, body {
height: 100%;
overflow: auto;
}
body {
padding: 0;
margin: 0;
}
</style>
</head>
<body>
<form id="form1" runat="server" style="height:100%;">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div style="height:100%;">
<asp:Silverlight ID="Silverlight1" runat="server" Source="~/ClientBin/SilverlightApplication1.xap" MinimumVersion="3.0.40307.0" Width="100%" Height="100%" />
</div>
</form>
</body>
</html>
答案 0 :(得分:0)
我不知道这是否相关(因为我自己成功使用了asp:Silverlight
控件),但是当我创建Silverlight项目时,Visual Studio在测试aspx页面中生成以下代码:
<form id="form1" runat="server" style="height:100%">
<div id="silverlightControlHost">
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
<param name="source" value="ClientBin/SilverlightApplication1.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="3.0.40624.0" />
<param name="autoUpgrade" value="true" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration:none">
<img src="http://go.microsoft.com/fwlink/?LinkId=108181" 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>
你可以尝试一下,看看它是否有所作为?因为这不是那么问题必须在其他地方。
您如何将用户控件包含在MainPage.xaml
?
答案 1 :(得分:0)
我刚刚将您的XAML粘贴到一个新项目中并在IE和FF中运行它,检查Silverlight应用程序部分中的Web项目属性是否引用了Silverlight项目。