# Legend adornment layer with background color

**URL:** <https://community.thinkgeo.com/t/legend-adornment-layer-with-background-color/2942>\
**Category:** WPF\
**Created:** [February 10, 2011, 1:04am UTC](https://community.thinkgeo.com/t/legend-adornment-layer-with-background-color/2942 "2011-02-10T01:04:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Keith](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/k/f05b48/32.png) [@Keith](https://community.thinkgeo.com/u/Keith)\
**Post date:** [February 10, 2011, 1:04am UTC](https://community.thinkgeo.com/t/legend-adornment-layer-with-background-color/2942/1 "2011-02-10T01:04:20Z")

</div>

&nbsp;

Hi&nbsp;all,&nbsp;

&nbsp;

I&nbsp;have&nbsp;been&nbsp;looking&nbsp;at&nbsp;the&nbsp;code&nbsp;sample&nbsp;for&nbsp;making&nbsp;an&nbsp;Legend&nbsp;Adornment&nbsp;Layer.&nbsp;[wiki.thinkgeo.com/wiki/Map\_S...ment\_Layer](http://wiki.thinkgeo.com/wiki/Map_Suite_Wpf_Desktop_Edition_All_Samples#Legend_Adornment_Layer)

I&nbsp;like&nbsp;to&nbsp;say&nbsp;the&nbsp;code&nbsp;sample&nbsp;is&nbsp;very&nbsp;helpful&nbsp;and&nbsp;provided&nbsp;a&nbsp;great&nbsp;starting&nbsp;points.&nbsp;

What&nbsp;is&nbsp;the&nbsp;best&nbsp;way&nbsp;to&nbsp;have&nbsp;the&nbsp;legent&nbsp;overlay&nbsp;present&nbsp;with&nbsp;a&nbsp;solid&nbsp;background&nbsp;color?&nbsp;As&nbsp;demostrated&nbsp;in&nbsp;the&nbsp;code&nbsp;sample,&nbsp;the&nbsp;adornment&nbsp;layer&nbsp;is&nbsp;transparent.&nbsp;This&nbsp;makes&nbsp;the&nbsp;legend&nbsp;very&nbsp;hard&nbsp;to&nbsp;see&nbsp;when&nbsp;you&nbsp;have&nbsp;other&nbsp;layers&nbsp;visible.

I&nbsp;have&nbsp;tired:

`legendBitmap = new Bitmap((int)legendIconWidth, (int)legendIconHeight );legendBitmap.MakeTransparent( Color.Gray );`

But&nbsp;it&nbsp;doesn't&nbsp;work.&nbsp;All&nbsp;I&nbsp;want&nbsp;to&nbsp;achieve&nbsp;is&nbsp;to&nbsp;place&nbsp;the&nbsp;legend&nbsp;inside&nbsp;a&nbsp;square&nbsp;gray&nbsp;rectangle.

Your&nbsp;assistnace&nbsp;will&nbsp;be&nbsp;very&nbsp;thanksful.&nbsp;

---

<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 10, 2011, 3:39am UTC](https://community.thinkgeo.com/t/legend-adornment-layer-with-background-color/2942/2 "2011-02-10T03:39:41Z")

</div>

&nbsp;

Hi&nbsp;Keith,  
First&nbsp;of&nbsp;all,&nbsp;Bitmap.MakeTransparent&nbsp;method&nbsp;is&nbsp;used&nbsp;for&nbsp;making&nbsp;the&nbsp;specified&nbsp;color&nbsp;transparent&nbsp;on&nbsp;the&nbsp;bitmap,&nbsp;you&nbsp;can&nbsp;see&nbsp;from&nbsp;the&nbsp;documentation&nbsp;on&nbsp;this&nbsp;API&nbsp;provided&nbsp;by&nbsp;Microsoft.&nbsp;So,&nbsp;maybe&nbsp;it&nbsp;won’t&nbsp;give&nbsp;you&nbsp;what&nbsp;you&nbsp;want&nbsp;in&nbsp;this&nbsp;case.  
In&nbsp;fact,&nbsp;there&nbsp;is&nbsp;a&nbsp;way&nbsp;to&nbsp;set&nbsp;background&nbsp;transparency&nbsp;of&nbsp;AdormantLayer.&nbsp;In&nbsp;the&nbsp;overridden&nbsp;DrawCore&nbsp;method&nbsp;of&nbsp;LengendAdornmentLayer,&nbsp;you&nbsp;have&nbsp;to&nbsp;add&nbsp;a&nbsp;code&nbsp;line&nbsp;at&nbsp;the&nbsp;end&nbsp;of&nbsp;this&nbsp;method:  
base.DrawCore(canvas,&nbsp;labelsInAllLayers);  
&nbsp;  
When&nbsp;initializing&nbsp;the&nbsp;LengedAdornmentLayer,&nbsp;you&nbsp;need&nbsp;to&nbsp;set&nbsp;the&nbsp;Width&nbsp;and&nbsp;Height&nbsp;property&nbsp;properly,&nbsp;and&nbsp;then&nbsp;set&nbsp;the&nbsp;BackgroundMask&nbsp;to&nbsp;the&nbsp;AreaStyle&nbsp;you&nbsp;want.&nbsp;Below&nbsp;is&nbsp;a&nbsp;code&nbsp;snippet&nbsp;that&nbsp;shows&nbsp;how&nbsp;to&nbsp;initialize&nbsp;the&nbsp;LengendAdormentLayer:  
&nbsp;LegendAdornmentLayer&nbsp;textAdornmentLayer&nbsp;=&nbsp;new&nbsp;LegendAdornmentLayer(10.0f,&nbsp;10.0f,&nbsp;winformsMap1.Overlays);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;textAdornmentLayer.Width&nbsp;=&nbsp;125;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;textAdornmentLayer.Height&nbsp;=&nbsp;100;  
&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;textAdornmentLayer.BackgroundMask.OutlinePen.Color&nbsp;=&nbsp;GeoColor.SimpleColors.BrightBlue;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;textAdornmentLayer.BackgroundMask.FillSolidBrush&nbsp;=&nbsp;new&nbsp;GeoSolidBrush(GeoColor.FromArgb(50,&nbsp;GeoColor.SimpleColors.Orange));  
&nbsp;  
&nbsp;  
Further&nbsp;questions&nbsp;please&nbsp;let&nbsp;me&nbsp;know.  
Thanks.  
James

---

<div class="post-metadata">

**Author:** ![David](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@David](https://community.thinkgeo.com/u/David)\
**Post date:** [February 10, 2011, 8:51am UTC](https://community.thinkgeo.com/t/legend-adornment-layer-with-background-color/2942/3 "2011-02-10T08:51:39Z")

</div>

Keith,&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;We&nbsp;have&nbsp;a&nbsp;new&nbsp;LegendAdornmentLayer&nbsp;in&nbsp;the&nbsp;works&nbsp;that&nbsp;is&nbsp;much&nbsp;more&nbsp;dynamic.&nbsp;&nbsp;We&nbsp;will&nbsp;keep&nbsp;you&nbsp;posted&nbsp;on&nbsp;that&nbsp;and&nbsp;may&nbsp;be&nbsp;able&nbsp;to&nbsp;send&nbsp;you&nbsp;the&nbsp;code&nbsp;if&nbsp;you&nbsp;are&nbsp;interested.&nbsp;&nbsp;We&nbsp;would&nbsp;appreciate&nbsp;your&nbsp;feedback!&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;&nbsp;  
&nbsp;David

---

<div class="post-metadata">

**Author:** ![Keith](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/k/f05b48/32.png) [@Keith](https://community.thinkgeo.com/u/Keith)\
**Post date:** [February 10, 2011, 6:18pm UTC](https://community.thinkgeo.com/t/legend-adornment-layer-with-background-color/2942/4 "2011-02-10T18:18:08Z")

</div>

David&nbsp;and&nbsp;James,&nbsp;

Thanks&nbsp;for&nbsp;the&nbsp;fast&nbsp;reply.&nbsp;

Would&nbsp;the&nbsp;new&nbsp;LegendAdornmentLayer&nbsp;be&nbsp;availble&nbsp;for&nbsp;download&nbsp;from&nbsp;the&nbsp;code&nbsp;library?&nbsp;I&nbsp;would&nbsp;very&nbsp;much&nbsp;like&nbsp;to&nbsp;have&nbsp;look&nbsp;at&nbsp;it&nbsp;and&nbsp;provide&nbsp;feedback&nbsp;to&nbsp;improve.&nbsp;

Or&nbsp;if&nbsp;you&nbsp;can&nbsp;please&nbsp;email&nbsp;it&nbsp;to&nbsp;mike&nbsp;(mikel@axim.com.au)&nbsp;for&nbsp;evaluation.&nbsp;Thank&nbsp;you&nbsp;for&nbsp;your&nbsp;assistance.&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![Keith](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/k/f05b48/32.png) [@Keith](https://community.thinkgeo.com/u/Keith)\
**Post date:** [February 10, 2011, 6:23pm UTC](https://community.thinkgeo.com/t/legend-adornment-layer-with-background-color/2942/5 "2011-02-10T18:23:33Z")

</div>

James,&nbsp;&nbsp;  
  
  
  
The&nbsp;code&nbsp;snippet&nbsp;you&nbsp;have&nbsp;mentioned&nbsp;to&nbsp;set&nbsp; **Width** , **&nbsp;Height** &nbsp;and&nbsp; **BackgroundMask** &nbsp;properties.&nbsp;But&nbsp;they&nbsp;are&nbsp;currently&nbsp; **not** &nbsp;present&nbsp;in&nbsp;the&nbsp;base.&nbsp;Are&nbsp;they&nbsp;newly&nbsp;introduced&nbsp;in&nbsp;the&nbsp;new&nbsp;LegendAdornmentLayer&nbsp;David&nbsp;has&nbsp;mentioned&nbsp;in&nbsp;above?

---

<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 11, 2011, 7:29pm UTC](https://community.thinkgeo.com/t/legend-adornment-layer-with-background-color/2942/6 "2011-02-11T19:29:10Z")

</div>

&nbsp;

Keith,  
All&nbsp;of&nbsp;the&nbsp;three&nbsp;properties&nbsp;were&nbsp;added&nbsp;to&nbsp;the&nbsp;AdornmentLayer&nbsp;right&nbsp;at&nbsp;the&nbsp;end&nbsp;of&nbsp;January&nbsp;this&nbsp;year&nbsp;in&nbsp;assembly&nbsp;MapSuiteCore.dll&nbsp;of&nbsp;version&nbsp;4.5.91,&nbsp;you&nbsp;need&nbsp;to&nbsp;update&nbsp;the&nbsp;assembly&nbsp;to&nbsp;this&nbsp;version&nbsp;or&nbsp;higher&nbsp;in&nbsp;order&nbsp;to&nbsp;apply&nbsp;these&nbsp;properties&nbsp;to&nbsp;AdornmentLayer,&nbsp;I&nbsp;didn’t&nbsp;make&nbsp;this&nbsp;point&nbsp;clear,&nbsp;sorry&nbsp;for&nbsp;the&nbsp;inconvenience.  
Further&nbsp;questions&nbsp;please&nbsp;let&nbsp;me&nbsp;know.  
PS:&nbsp;our&nbsp;Guru&nbsp;is&nbsp;working&nbsp;on&nbsp;the&nbsp;new&nbsp;Sample&nbsp;for&nbsp;LegendAdornmentLayer,&nbsp;I&nbsp;will&nbsp;let&nbsp;you&nbsp;know&nbsp;once&nbsp;he&nbsp;completed.  
Thanks.  
James
