In WebBrowser control get Silverlight Canvas - silverlight

I have a webbrowser control that loads an html page which contains a silverlight object.
I want to use the webbrowser control to get the silverlight canvas so that I can pass it to a WriteableBitmap() object.
The silverlight is being loaded into a div called SilverlightHostControl and I am trying to get it like this in C#:
object element = webBrowser.Document.GetElementById("SilverlightControlHost");
This returns a {System.Windows.Forms.HtmlElement} which contains the silverlight object but I don't know how to get the Silverlight object so I can use it the WriteableBitmap() object.

Further research shows that it can't be done.
The primary issue is that the Silverlight is running its own .Net version and the WinForm is running its own .Net version and never the two shall meet.

Related

ActiveX control in WPF

I am using a thrid party SDk to display video in my WPF application.
This requires me to add a control which is part of the SDK to the UI in order to display the video. I added the control to my WPF using the windows form host
ImageViewerControl _imageViewerControl = ClientControl.Instance.GenerateImageViewerControl();
WindowsFormsHost host = new WindowsFormsHost();
host.Child = _imageViewerControl;
grid1.Children.Add(host);
When I checked the grid1.children.count it is 1, also the _imageViewerControl is not null. Yet I do not see anything loaded on the UI.
But when I use WindowsForm everything works fine. What should I look for?

How to display HTML in Silverlight application?

I would need to display some basic HTML (just some paragraphs, unordered lists and hyperlinks) in my Silverlight application. How would I go about that?
Which control to use?
Try this link for starters: http://www.wintellect.com/CS/blogs/jprosise/archive/2009/12/22/silverlight-4-s-new-html-hosting-support.aspx
Here is the relevant part:
Another of the new capabilities that Silverlight 4 brings to the
platform is the ability to host HTML content inside a Silverlight
control. This support isn't limited to static HTML content; the
content can be interactive and can include script. It can even be
Flash content or content that includes other Silverlight controls.
To host HTML content in Silverlight, you can use either a WebBrowser
control or an HtmlBrush. One way to display HTML content is to fire up
a WebBrowser control and point it to a URL:
<WebBrowser x:Name="WebBrowserControl" Source="http://www.bing.com" />
Another way to do it is to call NavigateToString and pass a string of
content to the WebBrowser control:
WebBrowserControl.NavigateToString("<h1>Hello, Silverlight</h1>");
HTML hosting is not available to in-browser apps (it applies to
out-of-browser applications only), and if an OOB lacks elevated
permissions, it can only display content that comes from the same
domain as the Silverlight application. However, you can use a little
trick to display cross-domain content in OOBs that run without
elevated permissions—simply pass an IFRAME targeting the remote
content to NavigateToString:
WebBrowserControl.NavigateToString("<iframe src=\"http://www.bing.com\" style=\"width: 100%; height: 100%\"></iframe>");
You can render HTML content with HtmlBrush, too. The following XAML
snippet paints a Rectangle with content retrieved from Bing:
<WebBrowser x:Name="WebBrowserControl" Source="http://www.bing.com" />
<Rectangle>
<Rectangle.Fill>
<HtmlBrush SourceName="WebBrowserControl" />
</Rectangle.Fill>
</Rectangle>
One difference between WebBrowser and HtmlBrush is that the former
displays "live" content, while the latter does not. Another difference
is that HtmlBrush can have transforms applied to it, while WebBrowser
cannot. For snazzy visual effects involving HTML content like the HTML
puzzle demoed at the PDC, you'll probably find yourself using
HtmlBrush. To display live, interactive content, you'll find
WebBrowser more useful instead.
One of the really cool things about the WebBrowser control is that you
can use its InvokeScript method to call JavaScript functions in
content hosted by the control. Conversely, JavaScript hosted inside a
WebBrowser control can use window.external.Notify to raise
ScriptNotify events that can be handled in C#.
You could use HtmlBrush or webbrowser control.

How to embed IE (created using Watin) inside a WPF application [duplicate]

Can I embeded IE in my wpf application and interact with it firing events?
e.g. can I fill a form and press submit button programmatically?
Below is the link to the web browser control for WPF, this control was not part of the initial release of WPF, and was added in 3.5 SP1. As long as you are targeting 3.5 SP1 you can use this control and interact with the content in it. I have a WPF application that does use this control and we do a lot of JavaScript interactivity with the content from the browser by drawing on a WPF canvas and sending that information to the content API of the web browser control.
If you need an example I can look up some code samples from the application and send them your way.

Can I embeded IE in my wpf application and interact with it firing events

Can I embeded IE in my wpf application and interact with it firing events?
e.g. can I fill a form and press submit button programmatically?
Below is the link to the web browser control for WPF, this control was not part of the initial release of WPF, and was added in 3.5 SP1. As long as you are targeting 3.5 SP1 you can use this control and interact with the content in it. I have a WPF application that does use this control and we do a lot of JavaScript interactivity with the content from the browser by drawing on a WPF canvas and sending that information to the content API of the web browser control.
If you need an example I can look up some code samples from the application and send them your way.

opening a silverlight childWindow overlay on the viewport of the browser

I would like place a silverlight contol on an HTML page --- something about the size of a typical calendar control. However when the user selects a day on the control a bigger canvas opens up on top of the containing page --- something like a modal dialog box that you might find with the AJAX.
I'm wondering if this is even possible with Silverlight, or is the silverlight content limited in size to the DIV element on the host page?
UPDATE: after doing some poking around, I think the answer will involve using the ChildWindow control introduced with Silverlight 3. However I'm still at a loss how to have the ChildWindow display ontop of the existing content
I know one way, you will need javascript event on the page itself to expand a silverlight object to fit the whole page then build you silverlight event accordingly.

Resources