[英]How to make transparent background of Silverlight 3 application?
How to make transparent background of Silverlight 3 application? 如何制作Silverlight 3应用程序的透明背景? I have the next code but it does not work (
我有下一个代码,但它不起作用(
<html xmlns="http://www.w3.org/1999/xhtml" >
<!-- saved from url=(0014)about:internet -->
<head>
<title>BGtest</title>
<style type="text/css">
html, body {
height: 100%;
overflow: auto;
}
body {
padding: 0;
margin: 0;
}
#silverlightControlHost {
height: 100%;
text-align:center;
}
</style>
<script type="text/javascript">
function onSilverlightError(sender, args) {
var appSource = "";
if (sender != null && sender != 0) {
appSource = sender.getHost().Source;
}
var errorType = args.ErrorType;
var iErrorCode = args.ErrorCode;
if (errorType == "ImageError" || errorType == "MediaError") {
return;
}
var errMsg = "Unhandled Error in Silverlight Application " + appSource + "\n" ;
errMsg += "Code: "+ iErrorCode + " \n";
errMsg += "Category: " + errorType + " \n";
errMsg += "Message: " + args.ErrorMessage + " \n";
if (errorType == "ParserError") {
errMsg += "File: " + args.xamlFile + " \n";
errMsg += "Line: " + args.lineNumber + " \n";
errMsg += "Position: " + args.charPosition + " \n";
}
else if (errorType == "RuntimeError") {
if (args.lineNumber != 0) {
errMsg += "Line: " + args.lineNumber + " \n";
errMsg += "Position: " + args.charPosition + " \n";
}
errMsg += "MethodName: " + args.methodName + " \n";
}
throw new Error(errMsg);
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /></head>
<body bgcolor="#00FF00">
<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="BGtest.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="pluginbackground" value="Transparent" />
<param name="background" value="#80FF0000"/>
<param name="windowless" value="true" />
<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>
</body>
</html>
You've got a partially-transparent background there at the moment (#80FF0000). 目前,您那里的背景是部分透明的(#80FF0000)。 Why not change it to fully transparent like this:
为什么不将其更改为完全透明,如下所示:
<param name="background" value="transparent"/>
You can then draw whatever you want to be partially-transparent in your Silverlight app. 然后,您可以在Silverlight应用程序中绘制任何想要部分透明的内容。 However, be warned that transparent background with windowsless=true can be REALLY slow.
但是,请注意,使用windowsless = true的透明背景可能真的很慢。 It's better to avoid this using clever graphic design to fit the Silverlight control into the page, if possible.
如果可能的话,最好使用巧妙的图形设计来避免这种情况,以使Silverlight控件适合页面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.