.net - WPF control not displaying in ElementHost in WinForms app -


i have problem wpf control i'm trying host in elementhost in winforms app. control lookless custom control developed in separate test project, wpf app. in there works fine, in winforms app blank grey box elementhost displayed.

here's c# code creating, populating, , adding elementhost parent control:

// wpf control m_tabhostpanel  = new tabhostpanel(); m_elementhost  = new elementhost                  {                      child = m_tabhostpanel,                      dock = dockstyle.top,                      height = 34                  }; this.controls.add( m_elementhost ); 

the parent control contains other winforms controls added , removed @ runtime, needed. these hosted singly dock set dockstyle.fill. thus, every time add 1 send elementhost of z-order make sure renders correctly:

m_elementhost.sendtoback(); 

thus, know i'm not running airspace problem, or that.

the 1 thing did wonder this: in original project styles lookless controls merged resource dictionary application in app.xaml, this:

<application x:class="wpftestapp.app"              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"              startupuri="mainwindow.xaml">     <application.resources>         <resourcedictionary>             <resourcedictionary.mergeddictionaries>                 <resourcedictionary source="application/userinterface/datatemplates/tabmodeldatatemplate.xaml"/>                 <resourcedictionary source="application/userinterface/styles/hoverablepressablebuttonstyle.xaml"/>                 <resourcedictionary source="application/userinterface/styles/minicontrolbuttonstyle.xaml"/>                 <resourcedictionary source="application/userinterface/styles/tabclosebuttonstyle.xaml"/>                 <resourcedictionary source="application/userinterface/styles/tabscrollleftbuttonstyle.xaml"/>                 <resourcedictionary source="application/userinterface/styles/tabscrollrightbuttonstyle.xaml"/>                 <resourcedictionary source="application/userinterface/styles/tablistdropdownbuttonstyle.xaml"/>                 <resourcedictionary source="application/userinterface/styles/tabhostcomboboxstyle.xaml"/>                 <resourcedictionary source="application/userinterface/styles/tabbuttonstyle.xaml"/>                 <resourcedictionary source="application/userinterface/styles/tabhostpanelstyle.xaml"/>             </resourcedictionary.mergeddictionaries>         </resourcedictionary>     </application.resources> </application> 

i've migrated app.xaml winforms project, build action set page. if set applicationdefinition error saying application has multiple entry points, makes sense, i'm wondering if styles, etc., being picked up. if not might explain why i'm getting blank grey rectangle control should because, without these, there's nothing define look. maybe question is, how these styles winforms application wpf controls can see them?

i should mention running on .net fx 3.5.

anyway, i'm perplexed, gratefully received.

many thanks!

bart

thanks replying, think may misunderstand me: i'm trying use custom element, resources in application object, not insert application elementhost.

fortunately, i've found answer:

http://drwpf.com/blog/2007/10/05/managing-application-resources-when-wpf-is-hosted/

short version:

  • set build action app.xaml page
  • in code behind app.xaml create default constructor calls initializecomponent()
  • when winforms app starts up, create instance of app class.

and it's good: wpf control appears should.

now, why find answer after i've posted stackoverflow?

thanks again,

bart


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -