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

  • Home
  • SEARCH
  • 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 7609731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:14:40+00:00 2026-05-31T01:14:40+00:00

Set a button’s background is not as simple as android’s dev.it’s more complex; in

  • 0

Set a button’s background is not as simple as android’s dev.it’s more complex;

in .xaml file:

       <Button Click="Button_Click" x:Name="img_btn">
            <Button.Template>
                <ControlTemplate>
           <!--set button background that we can hanle click event-->
                    <Image  HorizontalAlignment="Left" Margin="0,-69,0,479" x:Name="image1" Stretch="Fill" Width="480" Source="/myNameSpace;component/home_003.jpg" />
                </ControlTemplate>
            </Button.Template>
        </Button>

in this .cs file:

                JsonObject jsonObject = (JsonObject)JsonObject.Load(e.Result);
                ads_address = jsonObject["imageurl"];//get a url from jsonobject
                ImageBrush imageBrush = new ImageBrush();
                imageBrush.ImageSource = new BitmapImage(new Uri(ads_address));//ads url likes //"http://27.98.194.93/forum/images/2009/home_004.jpg";

                this.img_btn.Background = imageBrush;//this code is not work,perhaps, I can't get what I want(Image) with code "this.img_btn.Background"

how can I get this Image in Button.If can’t what’s the way to set a button background with a url in code;

  • 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-31T01:14:42+00:00Added an answer on May 31, 2026 at 1:14 am

    try this

    Create image source at first and then giving that source to the image control you are using.

    string imagepath = “url”;

    ImageSource imgsrc1 = new BitmapImage(new Uri(imagepath, UriKind.RelativeOrAbsolute));
    //image can be Image/ImageBrush
    image.Source = imgsrc1;

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

Sidebar

Related Questions

I had a simple button set up with a background image defined like android:background=?attr/button
Why when I set enabled=false on a button does it not render correctly in
I am trying to set textColor property of button in android 2.1. But I
I've created a custom gallery; however, the Set wallpaper button will not set the
function abc(id, name){ var button = '<img src=/images/abc.png onclick=getvalue('+id+','+name+')/>'; $('Div1').set('html',button); } my this code
How can I set a button background image on iPhone under Monotouch? It will
I have a button with some background color, but when I set this button
function abc(id, name){ var button = '<img src=/images/abc.png onclick=getvalue('+id+','+name+')/>'; $('Div1').set('html',button); } my this code
I have an EditText and a Button set next to each other on the
I noticed that the height of a TToolButton increases when you set the button's

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.