Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Wpf in Winform

 
 
Old 03-12-2007   #1 (permalink)
DAve


 
 

Wpf in Winform

Hi,
I have a c# winform application in VS2005 and i add to that application a
wpf window (add new item -> Window(wpf))
now i chenge the build mode to the xaml to page and it compile ok but how do
i create instance of that window from my winform form and open the wpf
window????
thanks!



My System SpecsSystem Spec
Old 03-13-2007   #2 (permalink)
Laurent Bugnion [MVP]


 
 

Re: Wpf in Winform

Hi,

DAve wrote:
> Hi,
> I have a c# winform application in VS2005 and i add to that application a
> wpf window (add new item -> Window(wpf))
> now i chenge the build mode to the xaml to page and it compile ok but how do
> i create instance of that window from my winform form and open the wpf
> window????
> thanks!


I just tried, and I cannot even compile. However, the following works
for me:

- Add a new WPF project (WPF Custom control library for example).

- Add a Window to this WPF project

- In your WinForms project, reference the following libraries:
PresentationCore, PresentationFramework and WindowBase (from the .NET tab)

- In your WinForms code-behind, use:

private void button1_Click( object sender, EventArgs e )
{
CustomControlLibrary1.Window1 window
= new CustomControlLibrary1.Window1();
window.Show();
}

Let me know if it works.


Greetings,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Spell check recommendations (v1.1 WinForm) .NET General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46