WPF: how to remove MenuItem border -


so have simple menuitem:

<listview.contextmenu>     <contextmenu name="cmcopy">         <menuitem style="{staticresource menuitemdefaultstyle}" header="copy" click="menuitem_click"/>     </contextmenu> </listview.contextmenu> 

and style:

<style x:key="menuitemdefaultstyle" targettype="{x:type menuitem}">     <setter property="template">         <setter.value>             <controltemplate targettype="{x:type menuitem}">                 <grid snapstodevicepixels="true">                     <dockpanel>                         <contentpresenter x:name="icon" contentsource="icon" margin="4,0,6,0" snapstodevicepixels="{templatebinding snapstodevicepixels}" verticalalignment="center"/>                         <path x:name="glyphpanel" fill="{templatebinding foreground}" flowdirection="lefttoright" margin="7,0,0,0" visibility="collapsed" verticalalignment="center"/>                         <contentpresenter x:name="content" contentsource="header" width="40" margin="{templatebinding padding}" recognizesaccesskey="true" snapstodevicepixels="{templatebinding snapstodevicepixels}"/>                     </dockpanel>                     <popup x:name="part_popup" allowstransparency="true" focusable="false" horizontaloffset="1" isopen="{binding issubmenuopen, relativesource={relativesource templatedparent}}" popupanimation="{dynamicresource {x:static systemparameters.menupopupanimationkey}}" placement="bottom" verticaloffset="-1">                          <border borderthickness="0" borderbrush="transparent" background="{templatebinding background}">                             <scrollviewer x:name="submenuscrollviewer" cancontentscroll="true" style="{dynamicresource {componentresourcekey resourceid=menuscrollviewer, typeintargetassembly={x:type frameworkelement}}}">                                 <grid renderoptions.cleartypehint="enabled">                                     <itemspresenter x:name="itemspresenter" keyboardnavigation.directionalnavigation="cycle" grid.issharedsizescope="true" margin="2" snapstodevicepixels="{templatebinding snapstodevicepixels}" keyboardnavigation.tabnavigation="cycle"/>                                 </grid>                             </scrollviewer>                         </border>                     </popup>                 </grid>                 <controltemplate.triggers>                     <trigger property="ismouseover" value="true">                         <setter property="textblock.foreground" value="blue" targetname="content"/>                     </trigger>                 </controltemplate.triggers>             </controltemplate>         </setter.value>     </setter> </style> 

and want s remove border around menuitem.

and although defined this:'

<border borderthickness="0" borderbrush="transparent" background="{templatebinding background}"> 

i can still see black border brush.

update

enter image description here

mishka right, comes contextmenu style. here default style, see comment in want.

<color x:key="windowcolor">#ffe8edf9</color> <color x:key="contentareacolorlight">#ffc5cbf9</color> <color x:key="contentareacolordark">#ff7381f9</color>  <color x:key="disabledcontrollightcolor">#ffe8edf9</color> <color x:key="disabledcontroldarkcolor">#ffc5cbf9</color> <color x:key="disabledforegroundcolor">#ff888888</color>  <color x:key="selectedbackgroundcolor">#ffc5cbf9</color> <color x:key="selectedunfocusedcolor">#ffdddddd</color>  <color x:key="controllightcolor">white</color> <color x:key="controlmediumcolor">#ff7381f9</color> <color x:key="controldarkcolor">#ff211aa9</color>  <color x:key="controlmouseovercolor">#ff3843c4</color> <color x:key="controlpressedcolor">#ff211aa9</color>   <color x:key="glyphcolor">#ff444444</color> <color x:key="glyphmouseover">sc#1, 0.004391443, 0.002428215, 0.242281124</color>  <!--border colors--> <color x:key="borderlightcolor">#ffcccccc</color> <color x:key="bordermediumcolor">#ff888888</color> <color x:key="borderdarkcolor">#ff444444</color>  <color x:key="pressedborderlightcolor">#ff888888</color> <color x:key="pressedborderdarkcolor">#ff444444</color>  <color x:key="disabledborderlightcolor">#ffaaaaaa</color> <color x:key="disabledborderdarkcolor">#ff888888</color>  <color x:key="defaultborderbrushdarkcolor">black</color>  <!--control-specific resources.--> <color x:key="headertopcolor">#ffc5cbf9</color> <color x:key="datagridcurrentcellbordercolor">black</color> <color x:key="slidertrackdarkcolor">#ffc5cbf9</color>  <color x:key="navbuttonframecolor">#ff3843c4</color>  <lineargradientbrush x:key="menupopupbrush"                      endpoint="0.5,1"                      startpoint="0.5,0">   <gradientstop color="{dynamicresource controllightcolor}"                 offset="0" />   <gradientstop color="{dynamicresource controlmediumcolor}"                 offset="0.5" />   <gradientstop color="{dynamicresource controllightcolor}"                 offset="1" /> </lineargradientbrush>  <lineargradientbrush x:key="progressbarindicatoranimatedfill"                      startpoint="0,0"                      endpoint="1,0">   <lineargradientbrush.gradientstops>     <gradientstopcollection>       <gradientstop color="#000000ff"                     offset="0" />       <gradientstop color="#600000ff"                     offset="0.4" />       <gradientstop color="#600000ff"                     offset="0.6" />       <gradientstop color="#000000ff"                     offset="1" />     </gradientstopcollection>   </lineargradientbrush.gradientstops> </lineargradientbrush>  <style targettype="{x:type contextmenu}">   <setter property="snapstodevicepixels"           value="true" />   <setter property="overridesdefaultstyle"           value="true" />   <setter property="grid.issharedsizescope"           value="true" />   <setter property="hasdropshadow"           value="true" />   <setter property="template">     <setter.value>       <controltemplate targettype="{x:type contextmenu}">         <border x:name="border"                 background="{staticresource menupopupbrush}"                 borderthickness="1">           <border.borderbrush>             <solidcolorbrush color="{staticresource bordermediumcolor}" /><!-- set brush transparent -->           </border.borderbrush>           <stackpanel isitemshost="true"                       keyboardnavigation.directionalnavigation="cycle" />         </border>         <controltemplate.triggers>           <trigger property="hasdropshadow"                    value="true">             <setter targetname="border"                     property="padding"                     value="0,3,0,3" />             <setter targetname="border"                     property="cornerradius"                     value="4" />           </trigger>         </controltemplate.triggers>       </controltemplate>     </setter.value>   </setter> </style> 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -