Adding the XAML file in ASP.NET web Application - wpf

How do I add a XAML file to an ASP.NET web page?

Use the Silverlight control:-
<object type="application/x-silverlight" width="100%" height="100%" id="slc">
<param name="source" value="/myfolder/myfile.xaml"/>
</object>

Depends on what you want to do with that XAML file. :-)
If you want to use it with Silverlight, you need to learn how to write SL applications.
If you want to generate a static picture from the XAML to send to the client, you can look at this blog post.

Related

SharePoint 2013 - Silverlight WebPart XAP Cache

Good Morning,
I am new to sharepoint but I am pretty salty as far as silverlight goes. I know on a standard silverlight application hosted inside an ASP.NET app you can simply append .xap? here to make sure the xap files does not cache each time. In SharePoint I found only one article that even came close to exphttp://techblog.m-dd.com/index.php/2013/01/25/resolve-sharepoint-silverlight-webpart-caching-problem/. When I trying to Edit the WebPart and Under Application, provide path to .xap I click Configure. I then appent something like this to the end of the xap file: .xap?ver=1.1.1.0002 and recieve the following error in sharepoint: Cannot save all of the property settings for the Web Part. One or more errors have occured.
Any help would be greatly appricated.
Thanks
In my experience I've had a lot more luck by using a Content Editor Web Part and then embedding the tag which then links to the .xap file from there. Essentially you can edit the HTML source of the page by adding such a web part.
In the Content Editor Web Part, select "Edit Source" and paste something similar to this:
<object width="300" height="300"
data="data:application/x-silverlight-2,"
type="application/x-silverlight-2" >
<param name="source" value="/Library/YourSilverlight.xap?v=1"/>
</object>
See embedding Silverlight here: http://tz.nu/1o9pkSk
See more about adding the Content Editor Web Part here: http://tz.nu/1tSCOnJ
Using this approach, you can simply modify the page and edit the CEWP (Content Editor Web Part) and append the querystring behind the .xap to something unique (in my case, perhaps increment it to YourSilverlight.xap?v=2).
As an alternative to all of the above;
I've oftentimes developed my own base web part which hosts Silverlight .xap files, then I'll deploy and add that Web Part instead. I've often built-in the functionality for updated versions into the code so you never have to do that manually, but that's another story.

Silverlight Navigation + MVC Routing

I am experimenting with Silverlight (4.0) Navigation and deep linking. The problem I'm facing now is that my Silverlight application is hosted inside a MVC view page (.cshtml) as shown below, which is fairly standard.
<object id="SilverlightAdvanceAdminObject" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
<!-- omitted for brevity -->
</object>
At this stage, my URI is routed by MVC, so I would have a Admin controller which has a Advanced action which in turn returns the above view.
eg. http://localhost/Admin/Advanced
From here on out, I would like MVC to allow me to perform a Silverlight Navigation to 'deep link' into a view inside my SL app.
eg. http://localhost/Admin/Advanced#/Users
Uri Mapper:
<sdk:Frame region:RegionManager.RegionName="MainRegion">
<sdk:Frame.ContentLoader>
<prism:FrameContentLoader RegionName="MainRegion" />
</sdk:Frame.ContentLoader>
<sdk:Frame.UriMapper>
<sdk:UriMapper>
<sdk:UriMapping Uri="" MappedUri="/UserAdminView" />
<sdk:UriMapping Uri="/{viewName}" MappedUri="/{viewName}" />
</sdk:UriMapper>
</sdk:Frame.UriMapper>
</sdk:Frame>
The above example is something I would like to achieve, where the Users component of the URI is a view inside my SL application which is managed by a UriMapper. At the moment, this doesn't seem to work.
Any thoughts?
I would usually wait for an answer, but I found this problem to be a bit of a lemon. For the Silverlight applicaiton to receive the URI routes, you need to a an iframe with a specific id into the page hosting the SL.
<iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe>
I have no idea why this is not mentioned anywhere that can be easily seen, but apparently missed because if you use the Silveright Navigation project template, this would have been added for you automatically.
Good one MS! =.=

Silverlight Video File Won't Play; Can see .ism/manifest

I am running Windows Server 2008 SP2. I have an IIS 7.0 Webserver installed running IIS Media Services Beta 1. I also have WebDAV 7.5 installed.
I encoded a video file, MP4(H.264/AAC), to the smooth streaming protocol using Expression Encoder 4.0 Pro. Under "Default Web Site" I added a virtual directory to the encoded video and created a simple page with an embedded Silverlight player to view the content.
Simply put the page loads up, and never starts playing. If I go the the .ism file in a browser I can see it fine as an .xml.
I loaded up the default content that microsoft privides from http://www.microsoft.com/downloads/en/details.aspx?FamilyID=e44b0a2d-2e0c-48ff-bf57-3d05a20e2f6a&displayLang=en
If I try to play that file in the webpage it DOES work.
Here is my Question:
Why does the sample content work, but mine doesn't? Do I need to add some permissions somewhere so my file can be accessed? Was my file encoded incorrectly?
My File: http://128.113.16.8/library/kissxsis/1/1.ism/manifest
Sample File: http://128.113.16.8/library/bbb/Big%20Buck%20Bunny.ism/manifest
Edit1: Embed code for the player I am using to play the .ism
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
<param name="source" value="SmoothStreamingBlackGlass.xap"/>
<param name="minRuntimeVersion" value="4.0.50401.0"/>
<param name="autoUpgrade" value="true"/>
<param name="InitParams" value="mediaurl= http://128.113.16.8/library/kissxsis/1/1.ism/Manifest"/>
</object>
Silverlight's MediaElement can't play an ism directly - you need to use a smooth streaming player in a Silverlight app.
Which player are you using?
Are you using the Silverlight Media Framework Player or the Smooth Streaming Media Element?
Did you follow the deployment guide?

Hosting Silverlight widget from local file system

I'm trying to host a remote Silverlight widget in an html file that will exist locally on the hard drive, but whenever I open the html file, the Silverlight content does not show up. If I move the file to a web server and then access it through http, it works perfectly. I figured out (or at least I assume) that the widget is trying to make a call back to the web server but it's failing because of the cross zone restrictions in SL 2+. I've also seen a few reports from users talking about running into this issue when debugging from a local file. My question is, how can I tell for sure that this is the issue going on/what tools might I use to verify my hypothesis?
Additionally, (knowing full well that there are elevation of privileges security concerns to take into account) is there any way that I could declare the web services the widget calls as safe (for instance adding to the trusted sites) in such a way that Silverlight would be able to perform the calls without the security exceptions?
An example of a widget I'm talking about is below:
<object
type="application/x-silverlight-2"
data="data:application/x-silverlight-2,"
width="400" height="400">
<param name="minRuntimeVersion" value="3.0.40624.0" />
<param name="background" value="#141414" />
<param name="splashScreenSource"
value="http://memorabilia.hardrock.com/Widget/3.2009.1014.0/Splash.xaml" />
<param name="source"
value="http://memorabilia.hardrock.com/Widget/3.2009.1014.0/HardRock.Memorabilia.Silverlight.Widget.xap" />
<param name="enableHtmlAccess" value="true" />
<param name="initParams" value="item=034739" />
<a href="http://go.microsoft.com/fwlink/?linkid=149156&v=3.0.40624.0">
<img src="http://memorabilia.hardrock.com/Widget/3.2009.1014.0/Ping.gif?type=install&item=034739"
style="background:#141414
url(http://content.memorabilia.hardrock.com/Assets/Images/widget/034739.jpg)
no-repeat center;margin:0;padding:0;border:0;"
width="400" height="400" />
</a>
</object>
This is an issue of a cross protocol violation - a page with a file:// protocol cannot access assets with an http:// protocol. This also helps protect your your computer from accessed by a malicious Silverlight application.

How to embed Silverlight control in blog page?

How can I embed a demonstration applet written in Silverlight within a blog post? Is it possible to do so using any hosted blog engines, or only using a blog engine that I host myself?
I assume that I will need to use the same tags and .js as in a regular (X)HTML page with a SL control. Are there any hosted blog engines that will permit me to enter this? (Is it possible with blogger?)
Does the SL security model mean that the XAP file need to be hosted on the same site as the blog pages itself?
You can host a Silverlight app in HTML using the <object> tag, there is no need for the blog host to understand any of this. There is no server side element to hosting a Silverlight app its a purely client side thing.
<object id="SL" data="data:application/x-silverlight-2," type="application/x-silverlight-2" style="width:400px; height:300px">
<param name="source" value="MySLApp.xap" />
<param name="minRuntimeVersion" value="3.0.40624.0 />
<param name="initParams" value="someParam=value" />
<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" style="border-style: none" alt="Get Microsoft Silverlight" />
</a>
</object>
In this case the Silverlight app "MySLApp.xap" is placed in the same folder as the HTML page using it. However it could be on a different server if you like. However access to the HTML Bridge will be blocked but then if your app is self contained and does not need to communicate with the host page then there is no problem.
I created a Silverlight xap to host hero images OR video in my wordpress theme - I pass the content to it using initparams and custom fields per post.
That way I can use the same xap to host videos with media controls if appropriate or images with cool fade ins/click effects
example image post:
http://www.blackspike.com/site/html/display-google-docs-spreadsheets-in-wordpress
example video post (click vid for controls):
http://www.blackspike.com/site/wpf/hanselmans-babysmash
Both using the same xap!
An easy solution that worked for me is just to use an iFrame. So I published the regular TestPage.html generated by Visual Studio to my web site (along with the .XAP file of course) and then embedded it:
<iframe src="http://www.lostbearlabs.com/sl/Spring001/TestPage.html" frameborder="0" width="400" height="400" scrolling="no" ></iframe>
Using blogger, I discovered this gotcha: Any attempt to make the HTML pretty (e.g. by splitting it into separate lines) causes blogger to insert spurious <br> tags into the output, even if I do my edits using the "Edit HTML" view. So the iFrame tag must all be on a single line!!
You might want to check your host has the required MIME types mapped:
http://learn.iis.net/page.aspx/262/configuring-iis-for-silverlight-applications/
according to this Server 2008 IIS7 should work out of the box but IIS6 may require MIME types adding...
The solution marked as answer above works well if the HTML page and the Silverlight xap file are hosted on the same server.
As this is not possible in most of the cases, as most of the bloggers use either blogger/WordPress. We do not have any way of setting the mime type on these hosting providers.
Here is a good link which explains in detail regarding hosting an Silverlight application in blogger.

Resources