WasiF
WasiF

Reputation: 28919

How can I change the content "color" of a button in wpf

<StackPanel Margin="2">
  <Button Name="btn" Click="btn_Click" Content="Load Profile Image">
    <Button.Background>
      <ImageBrush ImageSource="D:\Pictures\rectangles.jpg"></ImageBrush>
    </Button.Background>
  </Button>
</StackPanel>

Image that i am pasting here is of is almost black, so I want to change the content color to white so that it should appear properly.

My apology, I hadn't added color in title which is quoted in commas, sorry for my mistake. Now it is OK, I think now it is clear to the reader ;)

Upvotes: 18

Views: 39370

Answers (3)

WasiF
WasiF

Reputation: 28919

In case you want to change the background and foreground of a button then do this

<Button Name="btn" Content="Load Profile Image">
   <Button.Background>
      <ImageBrush ImageSource="D:\Pictures\rectangles.jpg"></ImageBrush>
   </Button.Background>
   <Button.Foreground>
   <LinearGradientBrush StartPoint="0,0" EndPoint="1,1" >
       <GradientStop Color="YellowGreen" Offset="0.25" />
       <GradientStop Color="WhiteSmoke" Offset="1.5" />
   </LinearGradientBrush>
   </Button.Foreground>
</Button>

Upvotes: 1

Steve Mitcham
Steve Mitcham

Reputation: 5313

Assuming you are talking about the color of the Text you are displaying you want the Foreground property.

<Button Name="btn" Click="btn_Click" Content="Load Profile Image" Foreground="White">

Upvotes: 35

Muds
Muds

Reputation: 4116

I don't think we understand what you want here coz when you provide an image as background it will become background.

if you want Image , text and background to a button try this

 <Button Name="btn" Background="Red">
            <Button.Content>
                <Grid>
                    <Image Source="D:\Pictures\rectangles.jpg"></Image>
                    <TextBlock Text="Load Profile Image" ></TextBlock>
                </Grid>
            </Button.Content>
        </Button>

Upvotes: 0

Related Questions