Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3460060
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:11:02+00:00 2026-05-18T10:11:02+00:00

After several attempts to change the background of a button, and getting errors of

  • 0

After several attempts to change the background of a button, and getting errors of casting and things like that I finnaly got to this point:

Uri dir = new Uri("red_flag.png",UriKind.RelativeOrAbsolute);
ImageSource source = new System.Windows.Media.Imaging.BitmapImage(dir);
ImageBrush bru = new ImageBrush();
bru.ImageSource=source;
bru.Opacity = 100;

This code does not generate errors, but I can’t see the changes when I call:

button1.background = bru;

It just makes anything! 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T10:11:03+00:00Added an answer on May 18, 2026 at 10:11 am

    found the answer myelf after reading Mick’s answer, I share with you what I did:

    Uri dir = new Uri("red_flag.png", UriKind.Relative);
    ImageSource source = new System.Windows.Media.Imaging.BitmapImage(dir);
    Image image = new Image();
    image.Source = source;
    StackPanel stack = new StackPanel();
    stack.Children.Add(image);
    myButton.Content = stack;
    

    Thanks for your help

    Update 1:
    For best results set the padding property of your button to 0 (in each of the cases) so the image can resize automatically to fill all the button, please note this could hide your actual content, in my case this was what I wanted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

after several attempts, I can not solve this problem. I have the following mysql
so i have made several attempts at this, but decided i needed some advice
Background I've got the following tree of objects: Name Project Users nil John nil
I've been searching high and low for a satisfactory answer to this and failed.
I am trying to create an application that uses <authorization> rules to limit the
I'm developing a multitouch application. One touch is expected to move, and I need
I have set up an Unity 2.0.414.0 container using app config. My solution structure
I am new to Android development and I have a question about setting weight
I have a very annoying bug showing up. We have left our iPhone app

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.