I'm having a somewhat maddening issue just trying to get the Silverlight Pivot Control to work out of the box.
When I wire everything together, I see this stack trace in the JavaScript errors:
Unhandled Error in Silverlight Application Set property 'System.Windows.FrameworkElement.Style' threw an exception. [Line: 9 Position: 35] at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at VehiclePivotViewer.MainPage.InitializeComponent()
at VehiclePivotViewer.MainPage..ctor(IDictionary`2 initParams)
at VehiclePivotViewer.App.Application_Startup(Object sender, StartupEventArgs e)
at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)
I actually downloaded a helper library to dig further into that exception, and it looks like it's having a hard time with the MainPage.xaml markup, even though it all appears to be valid.
If it's helpful, I've listed the steps I took to set it all up below.
- Create a new MVC3 web application
- Create a Silverlight 4 application project in the same solution, and add it to the web project
- Add the five
System.Windows.Pivot
assembly references Add the control to my MainPage.xaml
<Grid x:Name="LayoutRoot" Background="White"> <Pivot:PivotViewer x:Name="Viewer" /> </Grid>
Wire up the collection URL:
Viewer.LoadCollection(initParams["CollectionUrl"], null);
- Set the appropriate values in the view:
`
<div id="silverlightControlHost">
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
<param name="source" value="ClientBin/xxxPivotViewer.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="4.0.50826.0" />
<param name="autoUpgrade" value="true" />
<param name="enableHtmlAccess" value="true" />
<param name="initParams" value="[email protected] %>" />
<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>
`
Anyone have any thoughts or suggestions? I'm extremely new to Silverlight, and am kinda sorta pulling my hair out.
It looks like you are missing <% in front of @ViewBag.CollectionUrl.