Limitations of using WebBrowser control to create WPF apps [duplicate] - wpf

I've recently stumbled across WebBrowser WPF control. I am interested if there are any limitations when building user interfaces with HTML+CSS+JS and embedding them in WebBrowser.
So far I've successfully
intercepted HTML click events and handled them in C# using
[ComVisible(true)] class attribute
called JS script from C# using InvokeScript method.
InvokeScript also supports sending objects to the HTML/JS via parameters which faciliates two way communication.
Is there any reason for not using using WebBrowser to create simple apps? I am intersted in parts that absolutely need to be handled with some WPF code and cannot be bridged using WebBrowser.

Related

various way in which window application can send data to web application using cef

How to send context data from wPF application to the WebApplication using CEF? Currently I am sending the data by using the functionality of CEF i.e. by executing Javascript on the brower, serching the control and then binding the value, is there any other way of doing the same?

How to cast from Windows.UI.Xaml.UIElement to System.Windows.Controls.UIElement

I'm trying to create a new UI for an app I developed for the Windows Store using the Windows Runtime API. This new client is going to be a WPF Desktop App. I'm trying to reuse as much code as I can but I'm facing several issues.
Fortunately there's a way to use WinRT in a WPF Desktop app (see this and this)
Now I'm blocked by the following issue:
The MediaCapture class has a method to start the preview of a device, after I've started the preview I can create a CaptureElement to display the preview.
CaptureElement is part of Windows.UI.Xaml.Controls and cannot be used in containers from System.Windows.Controls in which the WPF UI is built.
Am I going anywhere with this approach? what would you recommend? How can I display the preview of a device in the WPF app?
Thanks in advance
CaptureElement can't be used in desktop applications - the documentation says "[Windows Store apps only]". In general - the UI controls from WPF and WinRT/XAML can't be used outside of their respective domains (desktop/immersive UI). In a WPF app you need to use WPF controls - e.g. DirectShow for camera capture,

can we add silverlight application in tool box of asp.net web application

can we add silverlight application to tool box of asp.net web form application so that instead of writing HTML to include silverlight application i can just drag n drop it from tool box.
You can't add a silverlight app directly to the tool box. However its fairly simple to create a WebControl whose Render method writes out the appropriate <object> element with the source param pointing at your applications xap.
You can even add some properties from which that your render code could generate an initparams <param> element.
This WebControl would automatically end up in the ToolBox allowing you to drag it on the design surface.
You might even consider detecting that the control is rendering in the design time and change the output to display a reasonable placemarker for it in the designer.
Some versions ago Silverlight had a Silverlight Server control.
There is still one available here.

Recording Screen Interactions using UI Automation for Silverlight controls

I am trying to use UI Automation to record screen interactions in my Silverlight app. I have the Automation Peers for my control setup but am not able to figure out how to track these controls.
For my WPF app I would get hold of AutomationElement.RootElement and then navigate down to my App and setup Automation event Handlers on the controls I am interested in.
How would I do the same for Silverlight app? I want the screen recorder to start automatically whenever my app runs. The screen recorder has to sit within my App. But the System.Windows.Automation silverlight namespace doesn't have a AutomationElement class. So how would I do this in Silverlight?
Thanks
Shivaprasad
As you observed, the AutomationElement class doesn't exist in Silverlight: the UIAutomation API is available only in the full .Net framework. Silverlight is only supported as an UI Automation provider - that is, Silverlight applications can be controlled by UI Automation, but they are not able to control other applications.
For this reason, I don't think you're going to be able to create your screen recorder within the Silverlight application - unless you are prepared to resort to some nasty hacks.
Such hacks might include:
Using Silverlight COM Automation to call the new UIAutomation COM API. Users would be required to have the COM API installed on their machines in addition to Silverlight.
Create a "server" application in .Net that you can run on the target machine that does the actual UIAutomation work, then communicate with this from your Silverlight application using WCF.

How to access web application class into silverlight application

I am beginner in silverlight..I have created a silverlight project. When a new silverlight project is created it is automatically creating a silverlight application and one web application. I have added a class in both applications. Now I want to access a method of web application class into silverlight application class. Is it possible? I have tried to add web application reference to silverlight but VS is not allowing. Is there any another way to do??
What you need is called WCF. A really simple tutorial that should get you going is found here: How to call WCF methods from Silverlight controls
Fundementally WCF allows the silverlight client to make method calls on a class instance hosted on the web site.
Yes it is possible, but not in the normal way. A Silverlight assembly can only reference another Silverlight assembly (this is a limitation of VS2008, i don't know if it has been changed in VS2010).
What you need to do is add an existing file to your Silverlight project, when the file browse dialog opens you navigate to the class file you want to reuse, but instead of just clicking the Add button, click on the little down arrow on the button and choose Add as link - now the file will "exist" in both projects and can be used in both.
If you are going to do this repeatedly though, you will want to move those shared class files out into a separate assembly, do a project reference from your web app, and have the equivalent Silverlight class library mirroring it (sharing the files as links), and then project reference that Silverlight class library from your Silverlight app.

Resources