In WPF:
<Button Width="24" Height="24" >
<Image Source="pack://application:,,,/res/x.png" VerticalAlignment="Center"/>
</Button>
How can I mimic this in C#? I can't find any method in the Button
class that adds children.
Use the <input type="image"> Tag to Embed an Image in the HTML Button.
Save the XML file in your project res/drawable/ folder and then reference it as a drawable for the source of your ImageButton (in the android:src attribute). Android will automatically change the image based on the state of the button and the corresponding images defined in the XML.
Visual Studio 2015: create a button. create an image. set the source of the image to the right file of your resources (e.g. a . png file that you included to your project) drag the image over the button.
Button
is a Content
control so you just have to use the Buttons
Content
property
Example:
Button myButton = new Button
{
Width = 24,
Height = 24,
Content = new Image
{
Source = new BitmapImage(new Uri("image source")),
VerticalAlignment = VerticalAlignment.Center
}
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With