0

I am trying to create a button that has two triangles. One in the top right corner and one on the bottom left corner as shown below. And each would be displayed based on a boolean value (for example, ShowBottoCyan or ShowUpperGreen). I was hoping to do this in .xaml

I am using C#. I was trying polygons but having trouble understanding them.

enter image description here

1
  • You can use a LinearGradientBrush for the background (and even animate it). The "offsets" are little tricky ("off center"); but satisfying once you get them right. Commented Apr 1 at 17:53

1 Answer 1

3

You need the following Polygon elements in the Button element in your XAML code:

<Polygon x:Name="TopTriangle"
 Points="0,0 15,0 15,15" 
 Fill="Green"
 Stroke="Cyan"
 HorizontalAlignment="Right"
 VerticalAlignment="Top"
 Margin="3"/>

<Polygon x:Name="BottomTriangle"
 Points="0,0 0,15 15,15" 
 Fill="Cyan"
 Stroke="Cyan"
 HorizontalAlignment="Left"
 VerticalAlignment="Bottom"
 Margin="3"/>

Consider inverted cartesian product, top triangle points are:

x1,y1 x2,y2, x3,y3 = 0,0 15,0 15,15

And bottom triangle points are:

x1,y1 x2,y2, x3,y3 = 0,0 0,15 15,15

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.