|
I tried to setup a WPF Form in a Windows Form Application. When I tried to get a button on a form to load the WPF page. It didn't work. Does any one know if it possible to get a Windows Form to load a WPF Form.
|
| Joesoft11a Friday, May 15, 2009 10:58 PM |
Hi,
Yes this is possible.
To host a WPF form in a Win32 form you need to usethe ElementHost control. Drop this control on the Window and set it's Child property to the WPF form you want to display. www.dsmyth.net | www.dsmyth.net/wiki- Marked As Answer byHarry ZhuMSFT, ModeratorThursday, May 21, 2009 4:08 AM
-
|
| Derek Smyth Monday, May 18, 2009 8:57 AM |
Hello again joesoft11a
The two technologies, Win32 forms and WPF use very different technologies behind the scenes. Win32 using GDI+ and WPF uses DirectX to render to the controls on the screen. These two technologies can't work together without some sort of hosting (thats just a word, could be the wrong word, perhaps there is a better word). By that I mean a Win32 form cannot display WPF without the ElementHost control.
All i want to do is click on a button and load the WPF page.
Cool. You need to drop a ElementHost control on the form and then you need to load the WPF page (there is a class for that) and then set the Child property. Ok that was vague. I will create an example and repost. www.dsmyth.net | www.dsmyth.net/wiki- Marked As Answer byHarry ZhuMSFT, ModeratorThursday, May 21, 2009 4:07 AM
-
|
| Derek Smyth Tuesday, May 19, 2009 9:20 AM |
Hi,
Ok that was very simple.
On the Win32 form drop an ElementHost control and a button. Then add a new WPF user control to the project and design the WPFuser controlas you would normally. Then in the code behind the button add the following code.
WPFUserControl cntrl = new WPFUserControl(); this.elementHost1.Child = cntrl;
Where WPFUserControl is the WPF user control and elementHost1 is the ElementHost control.
www.dsmyth.net | www.dsmyth.net/wiki - Marked As Answer byHarry ZhuMSFT, ModeratorThursday, May 21, 2009 4:07 AM
- Proposed As Answer byRudedog2 Tuesday, May 19, 2009 5:01 PM
-
|
| Derek Smyth Tuesday, May 19, 2009 11:28 AM |
Hi, I'm not very familiar with TableAdapters I prefer to use a tool called NHibernate, it takes care of all my database stuff for me. :) There is a very good document on table adapters that might be worth reading. http://msdn.microsoft.com/en-us/library/bz9tthwx(vs.80).aspxThink thats it MSDN is slow. http://msdn.microsoft.com/en-us/library/7zt3ycf2.aspxCould be that one. It sounds like you haven't created a Fill/Get query.
www.dsmyth.net | www.dsmyth.net/wiki - Marked As Answer byHarry ZhuMSFT, ModeratorThursday, May 21, 2009 4:07 AM
-
|
| Derek Smyth Tuesday, May 19, 2009 4:17 PM |
Hi,
Yes this is possible.
To host a WPF form in a Win32 form you need to usethe ElementHost control. Drop this control on the Window and set it's Child property to the WPF form you want to display. www.dsmyth.net | www.dsmyth.net/wiki- Marked As Answer byHarry ZhuMSFT, ModeratorThursday, May 21, 2009 4:08 AM
-
|
| Derek Smyth Monday, May 18, 2009 8:57 AM |
Hi, Yes this is possible. To host a WPF form in a Win32 form you need to usethe ElementHost control. Drop this control on the Window and set it's Child property to the WPF form you want to display.
www.dsmyth.net | www.dsmyth.net/wiki
Hello Again Derek. Well I don't know what you mean by hosting it. All i want to do is click on a button and load the WPF page. |
| Joesoft11a Tuesday, May 19, 2009 2:07 AM |
Hello again joesoft11a
The two technologies, Win32 forms and WPF use very different technologies behind the scenes. Win32 using GDI+ and WPF uses DirectX to render to the controls on the screen. These two technologies can't work together without some sort of hosting (thats just a word, could be the wrong word, perhaps there is a better word). By that I mean a Win32 form cannot display WPF without the ElementHost control.
All i want to do is click on a button and load the WPF page.
Cool. You need to drop a ElementHost control on the form and then you need to load the WPF page (there is a class for that) and then set the Child property. Ok that was vague. I will create an example and repost. www.dsmyth.net | www.dsmyth.net/wiki- Marked As Answer byHarry ZhuMSFT, ModeratorThursday, May 21, 2009 4:07 AM
-
|
| Derek Smyth Tuesday, May 19, 2009 9:20 AM |
Hi,
Ok that was very simple.
On the Win32 form drop an ElementHost control and a button. Then add a new WPF user control to the project and design the WPFuser controlas you would normally. Then in the code behind the button add the following code.
WPFUserControl cntrl = new WPFUserControl(); this.elementHost1.Child = cntrl;
Where WPFUserControl is the WPF user control and elementHost1 is the ElementHost control.
www.dsmyth.net | www.dsmyth.net/wiki - Marked As Answer byHarry ZhuMSFT, ModeratorThursday, May 21, 2009 4:07 AM
- Proposed As Answer byRudedog2 Tuesday, May 19, 2009 5:01 PM
-
|
| Derek Smyth Tuesday, May 19, 2009 11:28 AM |
Hi, Ok that was very simple. On the Win32 form drop an ElementHost control and a button. Then add a new WPF user control to the project and design the WPFuser controlas you would normally. Then in the code behind the button add the following code. WPFUserControl cntrl = new WPFUserControl (); this .elementHost1.Child = cntrl; Where WPFUserControl is the WPF user control and elementHost1 is the ElementHost control.
www.dsmyth.net | www.dsmyth.net/wiki
Derek, Thanks. I owe you one. See what I was doing was that when I added a ElementHost1 to the forum. I thought it was a button. Well No it's the WPF Forum and the UserControl1 page gets displayed in the ElementHost1. Well maybe you can help me with one more thing. Since your good at this. In the UserControl1 form I wanted to add a SQL server database to it. I have the WPF Form all setup and all that. It just I have a video in the Data Entry in VB.NET. Well I tried the same sample in mine and can't get the Intelsince to see it. Samples: I Made a Database AddressBook.mdf with a connection string of AbookDataString Heres the 2nd line of code from th VC# sample.
private CustomerDataSetTableAdapters.CustomerTableAdapter taCust = new CustomerDataSetTableAdapters.CustomerTableAdapter();
and heres my line of code
private AbookDataSet AddressData = new AbookDataSet();
private AbookDataSetTableAdapters.AbookTableAdapter tabook = new AbookDataSetTableAdapters.AbookTableAdapter();
What happens is that the options for TableAdapter doesn't exist. So I'm stump. Any ideas |
| Joesoft11a Tuesday, May 19, 2009 12:59 PM |
Hi, I'm not very familiar with TableAdapters I prefer to use a tool called NHibernate, it takes care of all my database stuff for me. :) There is a very good document on table adapters that might be worth reading. http://msdn.microsoft.com/en-us/library/bz9tthwx(vs.80).aspxThink thats it MSDN is slow. http://msdn.microsoft.com/en-us/library/7zt3ycf2.aspxCould be that one. It sounds like you haven't created a Fill/Get query.
www.dsmyth.net | www.dsmyth.net/wiki - Marked As Answer byHarry ZhuMSFT, ModeratorThursday, May 21, 2009 4:07 AM
-
|
| Derek Smyth Tuesday, May 19, 2009 4:17 PM |
Hi, I'm not very familiar with TableAdapters I prefer to use a tool called NHibernate, it takes care of all my database stuff for me. :) There is a very good document on table adapters that might be worth reading. http://msdn.microsoft.com/en-us/library/bz9tthwx(vs.80).aspx Think thats it MSDN is slow. http://msdn.microsoft.com/en-us/library/7zt3ycf2.aspx Could be that one. It sounds like you haven't created a Fill/Get query.
www.dsmyth.net | www.dsmyth.net/wiki
Never Mind Derek. I'm sorry. I don't know why I just deleted every thing that that did it. Because it's Working. Thanks for you help and YES I owe you 2 now. |
| Joesoft11a Tuesday, May 19, 2009 4:37 PM |