tags:

views:

2957

answers:

4

Hi,

I want to create some up and down buttons using the standard button background but with black arrows.

What is the best way to do this with WPF??

Malcolm

+11  A: 

I find Marlett (a font built into Windows) handy for that sort of thing.

<Button FontFamily="Marlett" FontSize="20" Content="5"/>
<Button FontFamily="Marlett" FontSize="20" Content="6"/>
Matt Hamilton
Wow. I know this isn't as "WPF-y" as drawing a triangular polygon by hand, but still ... didn't expect down-votes.
Matt Hamilton
I reckon it's an OK way to go, what other interesting symbols are in the font?
Ian Oakes
Click Start|Run and type "charmap" - then you can switch to Marlett and have a look. I believe it's the font that Windows 95 originally used to render all its UI button glyphs.
Matt Hamilton
A: 

Hey thats cheating Matt :-)

Malcolm
+2  A: 

You can create a Polygon which represents your up and down triangles and then set them to be the content of the buttons:

<Button>
  <Polygon 
    Points="300,200 450,200 375,300 300,200"
    Stroke="Black">
    <Polygon.Fill>
      <SolidColorBrush Color="Black" />
    </Polygon.Fill>
  </Polygon>
</Button>

You can tweak these to draw different figured, but that's generally the XAML you would use for basic geometry.

casperOne
+7  A: 

No discussion on this subject would be complete without mentioning the geometry mini-language (or Path Markup Syntax) for a more compact shape definition:-

  <Button>
    <Path Fill="Black" Data="M 0 6 L 12 6 L 6 0 Z"/>
  </Button>
  <Button>
    <Path Fill="Black" Data="M 0 0 L 6 6 L 12 0 Z"/>
  </Button>

The first describes a Move to 0,6 Line to 12,6 Line to 6,0 and then close the shape (Z).

There is also a curve syntax.

Rhys