Silverlight ASP.NET透明背景

时间:2011-08-27 00:09:40

标签: asp.net silverlight background transparent

我刚刚开始学习Silverlight,但在我的asp.net页面中,我没有为我的Silverlight应用程序使用透明背景。我在互联网上搜索过,发现这两行应该解决它:

      <param name="background" value="Transparent" />
      <param name="pluginbackground" value="Transparent" />

但不幸的是没有。这是我嵌入Silverlight应用程序的方式:

<form id="form1" runat="server" style="height:100%">
    <div id="silverlightControlHost">
        <object data="data:SilverlightApplication4," type="application/x-silverlight-2" width="100%" height="100%">
          <param name="source" value="ClientBin/SilverlightApplication4.xap"/>
          <param name="onError" value="onSilverlightError" />
          <param name="background" value="Transparent" />
          <param name="pluginbackground" value="Transparent" />
          <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.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>

这是我的Silverlight代码:

<UserControl x:Class="SilverlightApplication4.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"
    d:DesignHeight="300" d:DesignWidth="400" Loaded="UserControl_Loaded" BorderBrush="Transparent">


    <StackPanel x:Name="LayoutRoot" Height="147" Width="226" Background="Transparent">
        <StackPanel.Resources>
            <Storyboard x:Name="FirstStoryBoard">
                <DoubleAnimation Storyboard.TargetName="FirstEllipse"
                          Storyboard.TargetProperty="Width"
                          To="1" AutoReverse="True"
                          Duration="00:00:01" />
            </Storyboard>
        </StackPanel.Resources>

        <TextBlock Text="Hello, World!" HorizontalAlignment="Center" Name="txtMessege" />
        <Ellipse Name="FirstEllipse" Height="100" Width="200" Fill="SlateBlue" />
        <Button Name="FirstButton" Width="100" Content="Click" Click="FirstButton_Click" />
    </StackPanel>

</UserControl>

1 个答案:

答案 0 :(得分:1)

尝试使用以下参数:

<param name="background" value="Transparent" />
<param name="windowless" value="True" />

您可能还需要重新启动浏览器。