Silverlight 3 - Can I run Out-of-browser inside another application - silverlight

The new Silverlight 3 beta includes the ability to run Out-of-Browser applications. The demos so far show this only inside a special frame. Does anyone know how I can run Siverlight 3 controls inside a (WPF) application?

No, you can not embed out-of-browser silverlight into WPF. The sllauncher.exe standalone frame has a special handler for the offline://(hostname).(revision)/ url given to it to allow the app to have all the features of out-of-browser mode (like extra keyboard access). Unless you can find a way to embed this app into your app, you won't be able to get out-of-browser; if you know some way to do this the address for this app is:
C:\Program Files\Microsoft Silverlight\3.0.40307.0\sllauncher.exe
As others have said, however, you can embed a silverlight control inside of an html page and that inside a WebBrowser element. Be cautious with this method, however, since there is currently no x64 support for Silverlight and if you absolutely must do this make sure to compile specifically for x86.

I'm guessing (yes, shame on me!) but you can probably put a WPF web browser on your window and navigate to the Silverlight app inside it.
This is a supported scenario; a recent MSDN article stated this scenario was supported, and scenarios like this forced the CLR team to allow multiple CLRs loaded into a single process.

It seems that SLOOB apps run inside a host process (C:\Program Files\Microsoft Silverlight\3.0.40307.0\sllauncher.exe). This hosts and sandboxes the app.
I suspect that it will not be possible to host it yourself - sorry if that's a little close to guessing, but short of running a hosting web browser in your WPF app I can't think of a way around the sandboxing requirement.
HTH

You can host a browser control inside a windows app, and load silverlight inside the browser control. This is how live mesh is going to do it.

Related

Is there are any loading speed difference between Page and Window in WPF?

I want to load 10 000 items in a DataGrid in WPF. When using a Window control the data loads faster than when using a Page control. Can someone explain why?
Pages are intended for use in Navigation applications (usually with
Back and Forward buttons, e.g. Internet Explorer). Pages must be
hosted in a NavigationWindow or a Frame
Windows are just normal WPF application Windows [lnk]
This is essentially an XBAP vs ClickOnce problem. Anything in a Page is compiled for and restricted by what WPF is permitted to do in a browser window. This precludes many low level computer operations that WPF Windows can get away with because they are compiled to run from the desktop. Window apps have full access to system resources.
Keep in mind that when you use a Page control, even during debugging, the generated code is build with a browser deployment in mind. All XBAPs are run in a restrictive security sandbox under partial trust. In other words, they are allowed to use certain .NET libraries but banned from accessing others. [ref] Some of these .NET libraries will be responsible for optimizations that therefore can't achieved in a browser deployment.
As such, it makes perfect sense that applications build in Windows would be able to perform most operations faster than apps built in Pages.

Alternatives to WebBrowser control in WPF?

We are working on a WPF app with the web browser control. When the user drags the window, the web browser lags behind the window as it drags.
Does anyone know how to solve this issue? Failing that, does anyone know an alternative to the web browser control itself?
Thanks!
Yes, as long as you don't require IE specific features you can use Awesomium which basically gives the same browser engine used by Google Chrome except for everything is rendered in pure WPF. For a while it was open source but I believe it is becoming a commercial product.
I haven't heard about any Native WPF WebBrowser Control. The only options I know are based on Win32 controls which are wrapped into WPF controls in order to displayed. (See more details at http://msdn.microsoft.com/en-us/library/ms752055.aspx )
Recently I have to use the WPF wrapper for the WebBrowser control, and it's very limited regarding the options available for the developer. During my research I found that you are able to inject scripts or html content in order to modify the page behavior. Also, you can call .NET code (e.g. CSharp function from Javascript).
However tasks such as accessing the cache, modifying cookies are difficult task or changing the web browser behavior are very difficult. Here is when you will have to use DLL Imports in order to invoke unmanaged routines (see http://msdn.microsoft.com/en-us/library/aa984739(v=vs.71).aspx )
It's possible to look for an alternative WebBrowser control such as:
http://code.google.com/p/csexwb2/
http://wpfchromium.codeplex.com/
I hope this helps
You can try CefSharp.Wpf which uses Chromium as a base browser. You can find it on NuGet

Can I replace WPF by Silverlight

Could Silverlight and WPF be interchangeable?
I mean, using Silverlight for Windows applications and WPF for web applications.
Silverlight and WPF are similar, but not interchangeable.
Silverlight and WPF are two different technologies intended to solve different problems. Silverlight has out-of-browser functionality, but must be delivered over the web in a browser first. WPF has XBAP, but it's still a WPF application. They are both XAML-based, so there is some limited ability to share resources.
If you are designing an application, select the technology that is most appropriate to the problem and the target audience. Keep in mind that while Silverlight runtime installs are growing fast, they still lag far behind others. Some people flatly refuse to install it. WPF apps can be distributed like desktop applications with an executable.
Update: In my experience, WPF XBAP applications don't behave well in browsers that aren't IE.
SL 4 can work in an out of browser mode. WPF has the XBAP (XAML browser application). So in a way they are but consider the limitations you may encounter in your projects.
Regards...
Some user controls can be reused between the two platforms. But because of the very different ways Silverlight and WPF interact with their environments (WPF on local system, Silverlight in browser plug-in sandbox) not all of the code is fully interchangable.
It's theoretically possible, but would require extra effort to port. And each is best suited to its environment. Here's an interesting discussion from an MS forum:
http://forums.silverlight.net/forums/p/1178/4244.aspx
For the most part, WPF is designed to run on the desktop and Silverlight and designed to run as part of a web page.
You can deploy a silverlight application to a desktop and run it from there, but there is no way to run a WPF UI "on the web".
With Silverlight 4 you can create a full trust application that is installed in the same was as a WPF application.
This article has a walkthrough.
So in this sense you can replace WPF with Silverlight.
You can link to WPF XAML pages on the web. This page has such a link, but you need a plugin to view it. I wouldn't want to deploy a full application this way though & I think it's only individual pages.

Call a method in a WPF app from Flash swf or exe

I'm working on a WPF app that needs to host some Flash content. The plan is create an exe from the Flash content, then invoke the exe from the WPF app (the option of hosting swf content inside a WebBrowser control was discussed but deemed to be too slow for this application). Is it possible for the Flash application to call a method in the hosting WPF app to provide some feedback? What IPC methods are available between Flash running as an exe and WPF?
I don't think this is a good design idea (i've toyed with these ideas before), but here is one lead:
http://blogs.vbcity.com/drydo/archive/2005/10/18/5586.aspx

Is any source code available that has an Active X control hosted in WPF?

I am looking for some source code and a project to download and look at that has an Active X control hosting WPF. I can not find any source code anywhere on the net.
I can not add a WPF resource the usual way in an Active X control. I have to add it manually to the reference section.
Not sure if this is even possible. I would check out WPF browser applications. That may be a better solution for you given that if you are going to be running an active x control with WPF the user will need 1) Internet Explorer and 2) .net 3.0+ installed locally. A WPF Browser application will work with IE if the user has .net 3.0+ installed and will work with IE and FireFox if the user has .net 3.5+ installed. Check out WPF Broswer Apps here: http://msdn.microsoft.com/en-us/library/aa970060.aspx
It should be possible, although I don't have the code for it off-hand. You can create an HwndSource, which allows a normal window to host WPF controls, in your ActiveX controls. Then it is only a matter of adding your WPF UI to that window.

Resources