c# - WPF custom context menu (resource dictionary) -
i've created custom style context menu. have put 3 lines of code under each widget(textbox):
<textbox.contextmenu> <contextmenu/> </textbox.contextmenu>
why have ? tooltip style works without code.
my context menu code:
<resourcedictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <color x:key="backgroundcolor" a="255" r="19" g="19" b="19"/> <bitmapimage x:key="bicut" urisource="images/cut.tif"/> <bitmapimage x:key="bicopy" urisource="images/copy.tif"/> <bitmapimage x:key="bipaste" urisource="images/paste.tif"/> <solidcolorbrush x:key="borderbrush" color="#ececec"/> <style targettype="contextmenu"> <setter property="foreground" value="{staticresource borderbrush}"/> <setter property="snapstodevicepixels" value="true" /> <setter property="overridesdefaultstyle" value="true" /> <setter property="grid.issharedsizescope" value="true" /> <setter property="template"> <setter.value> <controltemplate targettype="contextmenu"> <border borderthickness="1" borderbrush="#2468d9" padding="2" background="#131313"> <stackpanel orientation="horizontal"> <stackpanel orientation="horizontal" height="20"> <image source="{staticresource bicut}" width="20"/> <button content="ausschneiden" margin="5,0,0,0"/> <textblock text="strg+x" textalignment="center" verticalalignment="center" margin="5,0,0,0"/> </stackpanel> </stackpanel> </border> </controltemplate> </setter.value> </setter> </style> </resourcedictionary>
controls not have contextmenu
default (check property - null
). style not applied control. tooltip null
defult, filled tooltipservice
if necessary.
there no service fill contextmenu
of element. use default style (for control
).
Comments
Post a Comment