Windows Develop Bookmark and Share   
 index > Windows Forms General > Issue in elementhost
 

Issue in elementhost

I have created an On-screen-Keyboard as a WPF user control.
This WPF user control works fine (whenever i press a button,the text goes to the focused element) when used in a WPF application.

But when i use this WPF usercontrol in a Winform application using elementhost.child, the text doesnot go to any focused element in winform.

How do i route the OSk text content[when i press any key..i.e. button] to any focused element [eg: textbox] in winform?


rajesh_kumar  Tuesday, September 22, 2009 10:01 AM

Hi,

Sorry. Unfortunately, I am not able to reproduce this issue.

I drag a button and a textbox on the wpf UserControl:

namespace WpfControlLibrary1

{

/// <summary>

/// Interaction logic for UserControl1.xaml

/// </summary>

public partial class UserControl1 : UserControl

{

public UserControl1()

{

InitializeComponent();

}

private void button1_Click(object sender, RoutedEventArgs e)

{

textBox1.Text += "1";

textBox1.Focus();

}

}

}

In the winform application.

private void Form1_Load(object sender, EventArgs e)

{

ElementHost host = new ElementHost();

host.Dock = DockStyle.Fill;

WpfControlLibrary1.UserControl1 uc = new WpfControlLibrary1.UserControl1();

host.Child = uc;

this.Controls.Add(host);

}

When I click the button, the textbox show ��and get focus.

I think I must miss something. Could you please provide more details or make a demo project for us to test? Please upload your demo project to some server and offer us the URL. Skydrive (http://skydrive.live.com/ ) may be a good option. You can sign up 25GB free space only with your Windows Live Passport.

More information:

Walkthrough: Hosting a Windows Presentation Foundation Composite Control in Windows Forms

http://msdn.microsoft.com/en-us/library/ms745781.aspx

Best regards,

Ling Wang


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Monday, September 28, 2009 12:55 PM

We are changing the issue type to “General Discussion” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by opening the Options list at the top of the post window, and changing the type. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Sunday, October 04, 2009 7:33 AM

You can use google to search for other answers

Custom Search

More Threads

• Creating and Using Satellite Assembly using Visual Studio 2005
• Capturing AJAX events in Webbrowser control
• (National Instruments) Range Constructor
• Dynamic images master/detail page - Help.
• Wrappers for Windows Shell
• dynamically create control by type name
• What should localized RESX files contain
• How to use a .NET WinForm in COM Interop?
• make a control extend across splitter of splitcontainer
• Synchronize animated PictureBoxes