windows - How to get location in background of button c# -


i have button in xaml this

<button>   <button.background>     <imagebrush imagesource="/assets/image1xxx.png"/>   </button.background> </button> 

but in code behind(cs) how can string "assets/image1xxx.png" event. me. trying button_name.background.imagebrush.uri(), working

you have imagesource. bitmapimage. can urisource imagesource of imagebrush. try this:

    <button tapped="simplebutton_tapped">             <button.background>                 <imagebrush imagesource="assets/smalllogo.png"/>             </button.background>         </button> 

and in code behind:

  private void simplebutton_tapped(object sender, tappedroutedeventargs e)     {         if (sender button)         {             button button = sender button;             imagebrush imagebrush = button.background imagebrush;             bitmapimage image = new bitmapimage(new uri("ms-appx:/assets/othericon.png"));             imagebrush.imagesource = image;              bitmapimage bitmapimage = imagebrush.imagesource bitmapimage;             string imagesource = bitmapimage.urisource + "";             debug.writeline("the new imagesource of button is: " + imagesource);         }     } 

this following output:

imagesource : ms-appx:/assets/othericon.png


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -