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?
Related
I'm working on an ActiveX control which is hosted in MFC and VB6 applications.
This ActiveX contains a WPF control, itself hosted by a WinForms ElementHost, i.e.:
MFC > .NET ActiveX > WinForms ElementHost > WPF UserControl
When an user right-clicks on the control, he must be able to navigate in the contextual menu using the keyboard arrow keys.
If my control has the focus when the right-click occurs, everything works fine.
But if the focus is in the host application when the user right-clicks, keyboard events continue to be sent to the host MFC application.
I tried to call the Focus() method on my WPF control when I detect the right click, but it doesn't work.
Does anybody have an idea ?
Thanks.
I have found a workaround.
When the PreviewMouseRightButtonDown event occurs on the WPF form, I call the Focus method on the WinForm host control.
I don't really understand why, but this lets users use their keyboards to navigate in the contextual menu.
I have a hopefully trivial question. Currently, my company works with a rather obscure language (SyngergyDE) and we need to call a SilverLight application inside our product. Unfortunately, this obscure 3rd party language only (currently) supports the opening of WPF screens. So with that said, I thought I'd develop a small WPF user control that contains a "WebBrowser" control and navigate to the silverlight application's URI. This works fine, and I'm able to see the SL application. Here is my question - we have a "Close" button on the SL application, and when users "Click" that button, we want the window to close.
Does anyone have any suggestions on how we can communicate the "Closing of the SL App" to the WPF user control, so that the entire WPF user control closes as well?
Thanks everyone,
-Tom
Attach an event handler to the WebBrowser.Navigated event.
Have the close button in the Silverlight application use:-
HtmlPage.Window.Navigate(new Uri("about:blank", UriKind.Absolute));
When the Navigated event fires in WPF with the url "about:blank" then its time to close the control.
Use Javascript and the HTML DOM as the glue here.
For example, when the SL app close button is clicked, have Silverlight trigger some Javascript code that sets a flag, or alternately, raises some HTML document event.
The WPF control could poll that flag in the HTML + Javascript, or alternately listen for that HTML document event, then close the user control.
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?
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.
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.