c# - Drop down menu with checkboxes -


i have problem drop down menu in wpf because want code menu this:

combobox checkbox items , details

but i'm struggling , managed this:

combobox plain checkbox items

so i'm wondering if me make more in first example.

style (xaml):

    <style x:key="{x:type contextmenu}" targettype="{x:type contextmenu}">         <setter property="overridesdefaultstyle" value="true"/>         <setter property="snapstodevicepixels" value="true"/>         <setter property="fontsize" value="16"/>         <setter property="fontfamily" value="segoe ui light"/>         <setter property="template">             <setter.value>                 <controltemplate targettype="{x:type contextmenu}">                     <border background="#ff2e2f33"  opacity="1" width="190">                         <stackpanel cliptobounds="true" orientation="vertical" isitemshost="true" margin="0,5,0,0"/>                     </border>                 </controltemplate>             </setter.value>         </setter>     </style> 

xaml:

<textblock horizontalalignment="left" margin="12,114,0,0" verticalalignment="top" width="156" height="30" background="#ff2e2f33" fontfamily="segoe ui semibold" fontsize="16" foreground="white" text="kategorie" textwrapping="wrap"/>     <button  height="30" width="34" horizontalalignment="left" style="{dynamicresource buttonstyle2}" name="buttoncategory" verticalalignment="top" click="button1_click" margin="168,114,0,0" fontfamily="segoe ui symbol" fontsize="18.667" foreground="white" >         <button.content>             <path x:name="btnarrow" margin="4" verticalalignment="center"  stretch="uniform" horizontalalignment="right" data="f1 m 301.14,-189.041l 311.57,-189.041l 306.355,-182.942l 301.14,-189.041 z "/>         </button.content>         <button.contextmenu>             <contextmenu>                 <checkbox horizontalalignment="left" verticalalignment="top" content="category 1" template="{dynamicresource customcheckbox}" />                 <checkbox horizontalalignment="left" verticalalignment="top" content="category 2" template="{dynamicresource customcheckbox}" />                 <checkbox horizontalalignment="left" verticalalignment="top" content="category 3" template="{dynamicresource customcheckbox}" />                 <checkbox horizontalalignment="left" verticalalignment="top" content="category 4" template="{dynamicresource customcheckbox}" />             </contextmenu>         </button.contextmenu>     </button> 

c# code:

 private void button1_click(object sender, routedeventargs e)     {         (sender button).contextmenu.isenabled = true;         (sender button).contextmenu.placementtarget = (sender button);         (sender button).contextmenu.placement = system.windows.controls.primitives.placementmode.bottom;         (sender button).contextmenu.isopen = true;      } 


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -