Clyde Eisenbeis

Clyde Eisenbeis

  • 1.7k
  • 63
  • 11.9k

How do I create a rectangular button with a word?

May 20 2024 1:19 PM

I start with:

<Button>
    <Button.Content>
        <Rectangle Width="90" Height="20">
            <Rectangle.Fill>
                <SolidColorBrush Color="#444444" />
            </Rectangle.Fill>
        </Rectangle>
    </Button.Content>
</Button>

I want to place the word "Discarded" on the button.  I tried adding <TextBlock>Discarded</TextBlock>:

<Button>
    <Button.Content>
        <Rectangle Width="90" Height="20">
            <Rectangle.Fill>
                <SolidColorBrush Color="#444444" />
            </Rectangle.Fill>
        </Rectangle>
        <TextBlock>Discarded</TextBlock>
    </Button.Content>
</Button>

No matter where I insert <TextBlock>Discarded</TextBlock>, it results in an error. 

I also want a white Foreground.

 


Answers (1)