.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

Hook up AcceptButton to ElementHost

Posted By:      Posted Date: October 22, 2010    Points: 0   Category :Windows Application

Not sure if this belongs in the Winform or WPF forum... feel free to move if required.

.NET 4.0 WinForm project, VS 2010, WinXP SP3.


I've got a single WPF control I'm hosting in a ElementHost in my main WinForm application. It basically implements a System.Windows.Controls.Input.Toolkit.AutoCompleteBox because the native Winform textbox autocomplete is far too buggy for dynamic queries from a database, along with a Find button and a few radio buttons.

I'd like to hook up the WinForm AcceptButton to the WPF control's Find button, but of course one cannot simply do a direct assignment because they're different types of controls.  If you try, you'll get:

WpfSearch wpf = ehWpf.Child as WpfSearch;
this.AcceptButton = wpf.btnFind;

Cannot implicitly convert type 'System.Windows.Controls.Button' to 'System.Windows.Forms.IButtonControl'. An explicit conversion exists (are you missing a cast?)
Yes, I've already made the WPF Find button IsDefault, but that doesn't get translated over into the Winform apparently.


While I know I can intercept the Winform's KeyPress Event and check if it's the ENTER key, I'd rather a more 'natural' appro

View Complete Post

More Related Resource Links

attempting to hook up my printer to dell inspiron 1440

I recently purchased a lexmark 5650 all in one printer. I attempted to setup my printer in which I was successful all the way up to the end nearly. It pops up a screen that says : Required Software Not Installed, Microsoft .NET Framework Version 2.0 is required to continue. This software is available for free download at http://www.microsoft.com/downloads/ . Well when I go there I picked the (x64) version which I thought was the right one for my computer, then it tells me my computer already has that program as part of the operating system So my question is; Can anyone help me figure out how to get this thing to work right? Thank you.

IButtonControl instance for Form.AcceptButton

Hi, I want to support Esc key and Enter key for CancelButton and AcceptButton in my windows form application. I cannot directly use the buttons since they are ToolStripButton. Therefore, I have written a Wrapper like below extending the IButtonControl. The below thing works perfectly for the cancel button but not working for the AcceptButton. Please have a look and let me know if you have any idea. public struct IButtonWrapper : System.Windows.Forms.IButtonControl     {         public Action MyAction;         #region IButtonControl Members         public DialogResult DialogResult         {             get             {                 return System.Windows.Forms.DialogResult.None;             }             set             {             }         }         public void NotifyDefault(bool value)         {         }         public void PerformClick()        &nb

A User Control which contains a WPF Control hosted in ElementHost can not SHIFT+TAB back (but can TA

For some reason, user controls which are built out of WPF hosted controls, seem to be unable to SHIRT+TAB back out of the control on the form.  One can TAB forward to the next user control without issue, however, unless you wish to cycle the form, there is no way to go back.  To see this in action, create the following single user control:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
    public partial class TextForFun : UserControl
        System.Windows.Controls.TextBox wpfTextBox1 = new System.Windows.Controls.TextBox();
        MyElementHost myhost = new MyElementHost();

        public TextForFun(int point)

            myhost.Location = new Point(0, 0);
            myhost.Size = new Size(50, 50);

Hook up New WPF WebBrowser Events

Hi, is there anyone having successfully hooked up the events like mouseOver ect for the new WPF WebBrowser control ( 3.5 sp1)? I am having trouble to do so.
I don't know how to hook up the events with the WebBrowser.Document either. Please help, any sample file will be greatly appreciated.

Mark Luise

UserControl not refreshing in ElementHost control



I have a WinForms test app that I am using to work out the kinks of the WPF RibbonMenu Control....

I have a Winform form that I have placed an ElementHost on... I created a new WPF UserControl that I have  placed a RibbonMenu control on...

1st uc (MyMenu) design - I added a single Tab, a button and an image... this worked fine.

2nd uc (update to MyMenu) - I took the original User Control and added more Tabs, Groups and buttons etc... all is correct in the designer...

ISSUE when I go back to Form1 I see the ElementHost still but it shows the first version of the RibbonMenu and WILL NOT refresh.  I have deleted the ElementHost control saved and placed a new one of the form added the user control but it still shows the original not the new version of the menu.

The Tabs on the RibbonMenu control are there in code, and in the design interface for the WPF User Control... BUT when I run the app NO TABS????

Anyone got any suggestions?

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend