0

I have an WPF app and I am trying to know what is the best way to implement a kebab menu (three dots menu) button in WPF. Similar to this:

enter image description here

or similar to this in MS Edge (but vertical):

enter image description here

I am using .NET Standard 4.5

Willy
  • 9,848
  • 22
  • 141
  • 284
  • https://stackoverflow.com/questions/3526366/wpf-what-is-the-correct-way-of-using-svg-files-as-icons-in-wpf – Jodrell Nov 07 '22 at 12:59
  • if you are free to involve third party assets, you could include the fontawesome font where there's such an icon here: https://fontawesome.com/icons/ellipsis-vertical?s=solid&f=classic – Diego D Nov 07 '22 at 13:00
  • 2
    You can just use ⋮ – Andy Nov 07 '22 at 13:51
  • @Jodrell I am not able to understand what is the relationship between my question and the possible solution you proposed. – Willy Nov 09 '22 at 21:31
  • @DiegoD Thanks for the suggestion. Honestly I would like to avoid any third-party dependencies. – Willy Nov 09 '22 at 21:31
  • @Rodri if you want an Icon on a button, you could use a SVG for that icon. However, in this case, the "Kebab" has its own Unicode representation. – Jodrell Nov 10 '22 at 07:46

1 Answers1

3

This works for me:

    <Button VerticalAlignment="Top"
            HorizontalAlignment="Left"
            Width="30"
            Height="30">
        <TextBlock Text="⋮"/>
    </Button> 

Or alternatively using xml format character encoding

    <Button VerticalAlignment="Top"
            HorizontalAlignment="Left"
            Width="30"
            Height="30">
        <TextBlock Text='&#8942;'/>
    </Button>
Andy
  • 11,864
  • 2
  • 17
  • 20
  • Hi Andy, quick question if you don't mind. Why declaring a TextBlock inside the button and not set the the button's content property directly? – Kostas K. Nov 09 '22 at 10:25
  • When you set content on a button code in the button class ( or maybe it's buttonbase ) creates a textblock automatically and sets it's text property for you. I put a textblock so it's clear you could set font size or make it bold or whatever you like on that. But also. I tried a textblock first to prove I was going to get the three dots. Then pasted it in to a button. – Andy Nov 10 '22 at 16:08