2

In my wpf application I have a button. I want the button like to be background have an image and forground also have the image. How to do this?

Thanks in advance, Karn

karn
  • 51
  • 2
  • 4

2 Answers2

6

Not sure I understand what you want here, but here's two examples

Two different Images for foreground and background

<Button Content="Button" FontSize="50" Margin="0,0,263,155">
    <Button.Background>
        <ImageBrush ImageSource="C:\Time.png"/>
    </Button.Background>
    <Button.Foreground>
        <ImageBrush ImageSource="C:\C1.png"/>
    </Button.Foreground>
</Button>

alt text

Same Image as Foreground and Background

<Button Content="Button"
        FontSize="50"
        Foreground="{Binding RelativeSource={RelativeSource self}, Path=Background}">
    <Button.Background>
        <ImageBrush ImageSource="C:\Time.png"/>
    </Button.Background>
</Button>

alt text

Fredrik Hedblad
  • 83,499
  • 23
  • 264
  • 266
1

In general, you need to override the button's default appearance using a Style and / or a ControlTemplate.

For examples, you may want to see:

Feel free to provide more specifics or some code if you're having trouble, and we'll be able to help further.

Community
  • 1
  • 1
Dan J
  • 16,319
  • 7
  • 50
  • 82