# ElementHost and WPF

**URL:** <https://community.thinkgeo.com/t/elementhost-and-wpf/1017>\
**Category:** WinForms\
**Created:** [February 3, 2010, 10:37am UTC](https://community.thinkgeo.com/t/elementhost-and-wpf/1017 "2010-02-03T10:37:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter6](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/p/e5b9ba/32.png) [@Peter6](https://community.thinkgeo.com/u/Peter6)\
**Post date:** [February 3, 2010, 10:37am UTC](https://community.thinkgeo.com/t/elementhost-and-wpf/1017/1 "2010-02-03T10:37:38Z")

</div>

We&nbsp;are&nbsp;seeing&nbsp;some&nbsp;strange&nbsp;sizing&nbsp;results&nbsp;of&nbsp;the&nbsp;WPF&nbsp;control&nbsp;when&nbsp;we&nbsp;host&nbsp;it&nbsp;inside&nbsp;a&nbsp;winforms&nbsp;MDI&nbsp;windows&nbsp;applicaiton.

We&nbsp;have&nbsp;our&nbsp;WPF&nbsp;usercontrol&nbsp;which&nbsp;contains&nbsp;the&nbsp;map&nbsp;control&nbsp;on&nbsp;bottom&nbsp;and&nbsp;a&nbsp;ribbon&nbsp;control&nbsp;on&nbsp;top.&nbsp;&nbsp;This&nbsp;looks&nbsp;fine&nbsp;just&nbsp;as&nbsp;a&nbsp;WPF&nbsp;control&nbsp;but&nbsp;when&nbsp;we&nbsp;host&nbsp;it&nbsp;in&nbsp;a&nbsp;winforms&nbsp;app,&nbsp;The&nbsp;control&nbsp;seems&nbsp;to&nbsp;not&nbsp;recognize&nbsp;the&nbsp;bondaries&nbsp;of&nbsp;our&nbsp;WPF&nbsp;stack&nbsp;panel&nbsp;but&nbsp;instead&nbsp;resizes&nbsp;to&nbsp;the&nbsp;boundaries&nbsp;of&nbsp;the&nbsp;winforms&nbsp;window.&nbsp;&nbsp;Is&nbsp;this&nbsp;a&nbsp;know&nbsp;issue&nbsp;with&nbsp;hosting&nbsp;the&nbsp;WPF&nbsp;control&nbsp;inside&nbsp;a&nbsp;winforms&nbsp;app?&nbsp;

---

<div class="post-metadata">

**Author:** ![Peter6](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/p/e5b9ba/32.png) [@Peter6](https://community.thinkgeo.com/u/Peter6)\
**Post date:** [February 3, 2010, 1:18pm UTC](https://community.thinkgeo.com/t/elementhost-and-wpf/1017/2 "2010-02-03T13:18:06Z")

</div>

I&nbsp;attached&nbsp;an&nbsp;example&nbsp;of&nbsp;what&nbsp;I'm&nbsp;seeing.&nbsp;&nbsp;The&nbsp;attachement&nbsp;is&nbsp;a&nbsp;windows&nbsp;form&nbsp;which&nbsp;contains&nbsp;a&nbsp;ElementHost.

The&nbsp;WPF&nbsp;control&nbsp;is&nbsp;what&nbsp;you&nbsp;see&nbsp;inside&nbsp;the&nbsp;Element&nbsp;Host&nbsp;at&nbsp;runtime.&nbsp;&nbsp;You&nbsp;can&nbsp;see&nbsp;the&nbsp;map&nbsp;control&nbsp;on&nbsp;top&nbsp;of&nbsp;the&nbsp;ribbon&nbsp;control.&nbsp;&nbsp;When&nbsp;look&nbsp;at&nbsp;this&nbsp;control&nbsp;inside&nbsp;a&nbsp;WPF&nbsp;app,&nbsp;the&nbsp;map&nbsp;window&nbsp;is&nbsp;below&nbsp;and&nbsp;the&nbsp;ribbon&nbsp;is&nbsp;above.&nbsp;&nbsp;Both&nbsp;are&nbsp;contained&nbsp;inside&nbsp;a&nbsp;grid.

[1725-Interop.JPG](https://community.thinkgeo.com/uploads/default/original/2X/5/50292c0b8c083845e459cc56d79f6ffcb748ae28.JPG) (10.4 KB)

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [February 4, 2010, 1:06am UTC](https://community.thinkgeo.com/t/elementhost-and-wpf/1017/3 "2010-02-04T01:06:55Z")

</div>

Peter,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;post.&nbsp;  
&nbsp;&nbsp;  
&nbsp;We&nbsp;can&nbsp;not&nbsp;recreate&nbsp;your&nbsp;problem.&nbsp;In&nbsp;order&nbsp;to&nbsp;solve&nbsp;your&nbsp;problem&nbsp;and&nbsp;make&nbsp;the&nbsp;problem&nbsp;clear,&nbsp;could&nbsp;you&nbsp;provide&nbsp;a&nbsp;simple&nbsp;sample?&nbsp;That&nbsp;way&nbsp;we&nbsp;can&nbsp;go&nbsp;directly&nbsp;to&nbsp;resolving&nbsp;your&nbsp;problem&nbsp;instead&nbsp;of&nbsp;spending&nbsp;time&nbsp;setting&nbsp;up&nbsp;your&nbsp;scenario&nbsp;and&nbsp;trying&nbsp;to&nbsp;recreate&nbsp;the&nbsp;error&nbsp;on&nbsp;our&nbsp;side.&nbsp;If&nbsp;you&nbsp;don’t&nbsp;fell&nbsp;comfortable&nbsp;sending&nbsp;your&nbsp;project&nbsp;in&nbsp;the&nbsp;Discussion&nbsp;Forum,&nbsp;you&nbsp;can&nbsp;use&nbsp;one&nbsp;of&nbsp;your&nbsp;Support&nbsp;tickets&nbsp;in&nbsp;the&nbsp;Customer&nbsp;Portal.&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;James&nbsp;

---

<div class="post-metadata">

**Author:** ![Peter6](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/p/e5b9ba/32.png) [@Peter6](https://community.thinkgeo.com/u/Peter6)\
**Post date:** [February 4, 2010, 2:41pm UTC](https://community.thinkgeo.com/t/elementhost-and-wpf/1017/4 "2010-02-04T14:41:16Z")

</div>

Thanks&nbsp;for&nbsp;the&nbsp;response.&nbsp;&nbsp;I&nbsp;figured&nbsp;out&nbsp;the&nbsp;problem.&nbsp;&nbsp;If&nbsp;I&nbsp;set&nbsp;the&nbsp;top&nbsp;margin&nbsp;of&nbsp;my&nbsp;usercontrol,&nbsp;which&nbsp;holds&nbsp;the&nbsp;ThinkGeo&nbsp;control,&nbsp;to&nbsp;some&nbsp;value.&nbsp;&nbsp;That&nbsp;usercontrol&nbsp;doesn’t&nbsp;overlap&nbsp;the&nbsp;control&nbsp;above&nbsp;it.&nbsp;&nbsp;My&nbsp;situation&nbsp;was&nbsp;we&nbsp;had&nbsp;a&nbsp;WPF&nbsp;usercontrol&nbsp;which&nbsp;contained&nbsp;two&nbsp;other&nbsp;user&nbsp;controls.&nbsp;&nbsp;One&nbsp;was&nbsp;a&nbsp;ribbon&nbsp;and&nbsp;the&nbsp;other&nbsp;was&nbsp;the&nbsp;ThinkGeo&nbsp;Map.&nbsp;&nbsp;As&nbsp;long&nbsp;as&nbsp;I&nbsp;make&nbsp;sure&nbsp;the&nbsp;master&nbsp;control&nbsp;sets&nbsp;the&nbsp;Margin&nbsp;of&nbsp;any&nbsp;sub&nbsp;user&nbsp;controls&nbsp;correctly&nbsp;instead&nbsp;of&nbsp;assuming&nbsp;a&nbsp;Grid&nbsp;will&nbsp;take&nbsp;care&nbsp;of&nbsp;positioning,&nbsp;everything&nbsp;works&nbsp;great.

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [February 4, 2010, 5:53pm UTC](https://community.thinkgeo.com/t/elementhost-and-wpf/1017/5 "2010-02-04T17:53:27Z")

</div>

Peter,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;sharing,&nbsp;I&nbsp;am&nbsp;glad&nbsp;you&nbsp;are&nbsp;making&nbsp;progress.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Any&nbsp;more&nbsp;questions&nbsp;just&nbsp;feel&nbsp;free&nbsp;to&nbsp;let&nbsp;me&nbsp;know.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Yale&nbsp;
