c# - how to set image width dynamically in windows phone 8.1? -


i want set width dynamically added button background image.

this code

buttob btn=new button();  imagebrush brush1 = new imagebrush();  brush1.imagesource = new bitmapimage(new uri("ms-px:///assets/emptyseat.jpg"));    btn.background = brush1; 

how set width of above image dynamically.

you can scale image creating scaletransform object , applying imagebrush, , setting stretch property on brush whatever desire.

for example:

        button btn = new button();         imagebrush brush1 = new imagebrush();                     brush1.imagesource = new bitmapimage(new uri("ms-appx:///assets/emptyseat.jpg"));          scaletransform scaletransform = new scaletransform();         scaletransform.scalex = 0.5;         brush1.transform = scaletransform;         brush1.stretch = stretch.uniform;          btn.background = brush1; 

it's not entirely clear trying achieve above resize image you.


Comments