I am new to SilverLight and I am trying to replicate a simple example from the book “Pro Silverlight 5 in C#” by Matthew MacDonald.
I am using VS2012 to create Silverlight 5 application.
When I run SilverlightApplication1TestPage.html – it works in IE10, but in FF and Chrome I get a blank page. The SilverLight plugin loads in these browsers but does not show anything.
Please give me any suggestions as to why this is happening.
The MainPage.xaml code is as follows.
<UserControl x:Class="SilverlightApplication1.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">
<Grid x:Name="LayoutRoot" Background="White">
<StackPanel>
<TextBlock x:Name="lblMessage" Text="Hello World!" Margin="5"></TextBlock>
<Button x:Name="cmdClickMe" Content="Click Me!" Margin="5" Click="cmdClickMe_Click" />
</StackPanel>
</Grid>
The MainPage.xaml.cs contains the following handler.
private void cmdClickMe_Click(object sender, RoutedEventArgs e)
{
lblMessage.Text = "Goodbye, cruel world.";
}
The html page looks as follows (the body portion).
<body>
<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="SilverlightApplication1.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="5.0.61118.0" />
<param name="autoUpgrade" value="true" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=5.0.61118.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>
The problem was that the Silverlight project directory was located under “C:\Users\<USER>\Documents\Visual Studio 2012\Projects”, where <USER> was not written in English.
I moved the .html and .xap files to C:\ and the projected worked fine in all browsers.