Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create custom "+" button in WPF

Tags:

wpf

I've been attempting to create a customized plus button in WPF. I only want the + symbol but I'm not having any luck getting the Path data variables just right. I've looked at the Path syntax but I'm still having trouble.

This is what I have so far, but it is too big. I need a smaller, more proportional button:

<Path
        Stretch="Fill"
        Opacity="1"
        x:Name="path"
        StrokeThickness="10"
        RenderTransformOrigin="0.5,0.5" Margin="39,56.75,39,65.25" Data="M0,5L10,5 M5,5L5,1z" >

Can anyone tell me what I've got wrong here?

Thanks

like image 727
Encryption Avatar asked Nov 29 '22 18:11

Encryption


1 Answers

You can use the Data property like this

<Button>
    <Path Data="M0.5,0 L0.5,1 M0,0.5 L1,0.5"
          StrokeThickness="4"
          Stretch="Fill"
          Stroke="Red" />
</Button>

Looks like this

enter image description here

Edit
If you want the line caps to reach the edges of the Button you can set

StrokeEndLineCap="Square"
StrokeStartLineCap="Square"
like image 79
Fredrik Hedblad Avatar answered Dec 18 '22 22:12

Fredrik Hedblad