I have the following and am trying to use an alternative syntax to set the property element but the button now seems to be filling the whole page:

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

  <Button
    x:Name="bluebutton"
    Width="100"
    Height="40"
    Content="Click Me" />

    <!--Background="Blue"-->
    <Button>
      <Button.Background>
        <SolidColorBrush Color="Blue" />
      </Button.Background>
    </Button>

</Page>

How do I still use this alternative syntax but apply the color to bluebutton ?

1 Answers

1
John On Best Solutions

There are two buttons in your code. Perhaps you wanted to do this:

    <Button
x:Name="bluebutton"
Width="100"
Height="40"
Content="Click Me">
        <Button.Background>
            <SolidColorBrush Color="Blue" />
        </Button.Background>
    </Button>