User avatar
digimbyte
Topic Author
Posts: 47
Joined: 14 Nov 2017, 21:42

Image on Button?

17 Jun 2019, 13:18

I'm looking at creating icons on buttons using textures
but I don't want to replace the existing background
is that possible?
My current code snippet, but it replaces the background of the entire button. is there an overlay or a content control that accepts images?
        BottomDock.Children.Add(new Button
        {
            Content = "test",
            Height = BottomStack.Height,
            MinWidth = 40,
            Background = new Noesis.ImageBrush
            {
                ImageSource = source,
                Stretch = Stretch.Uniform
            }
        });
my goal is to replicate this Image
 
User avatar
sfernandez
Site Admin
Posts: 2991
Joined: 22 Dec 2011, 19:20

Re: Image on Button?

17 Jun 2019, 16:47

The Button is a content control, so it provides a Content property you can set with an Image:
BottomDock.Children.Add(new Button
  {
    Height = BottomStack.Height,
    MinWidth = 40,
    Content = new Image
    {
      Source = source,
      Stretch = Stretch.Uniform
    }
});
Is this what you want?
 
User avatar
digimbyte
Topic Author
Posts: 47
Joined: 14 Nov 2017, 21:42

Re: Image on Button?

17 Jun 2019, 23:52

I've tried attaching the image as the content before, I ended up with the name of the texture as text, so I assumed I was doing something wrong.

Thanks!

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 18 guests