wpf form with exceldna

644 views
Skip to first unread message

Arun Kumar

unread,
Dec 14, 2017, 11:06:32 AM12/14/17
to Excel-DNA

hello guys some one please help me

i am just a newbie programmer and have created few winforms with exceldna.thanks to the group, it helped me a lot. Can some one point me how to add a wpf form? i cant find WPF form after creating class library and setting up excel addin. (in ADD-> new item, i can see only user control wpf).

well i googled and found some examples which i don't understand quite good. any help is appreciated.

I am using visual studio visual 2017.

Thank you

Raymond Gota Toudji

unread,
Dec 14, 2017, 5:41:54 PM12/14/17
to Excel-DNA
Hi Arun,

You don't need a wpf form. This is what I do:
- create like usual an old fashion winform
- place in it an ElementHost (from the wpf interopability group in the toolbox at the bottom). It's a System.Windows.Forms.Integration.ElementHost class.
It can hold a wpf usercontrol, making it possible to let a winform host a wpf object:

If you really want a wpf form/window very badly, you can add one programmatically at run-time and put your wpf usercontrol from design-time in it:
Dim wpfWindow As System.Windows.Window = New System.Windows.Window
wpfWindow.Content = New UserControl1 'Your design-time wpf usercontrol
wpfWindow.Show()

I hope this helped.
Raymond.


Op donderdag 14 december 2017 17:06:32 UTC+1 schreef Arun Kumar:
Reply all
Reply to author
Forward
0 new messages