Anonymous 1317
I'm writing a small test tool which is an UWP app. I have a custom icon called MyIcon.png in Assets/Images.
There is a button defined as below:
```
<Button Command="{x:Bind ViewModel.DoSomethingBtnClick}"
Grid.Column="3" Grid.Row="0"
Margin="30,20,0,0" VerticalAlignment="Top" Width="95" Height="70">
<StackPanel>
<!--I want to add the icon here -->
<TextBlock Text="Do Something" TextWrapping="WrapWholeWords" HorizontalTextAlignment="Center"/>
</StackPanel>
</Button>
```
How do I add the icon to the button?
Top Answer
Joan Magnet
If you don't want to use a glyph, you can use an image in the usual way:
```
<Button>
<StackPanel>
<Image/>
<TextBlock/>
</StackPanel>
</Button>
```
Have a look at this answer on SO:
https://stackoverflow.com/questions/41191758/uwp-xaml-how-to-display-a-button-with-icon-and-text-in-it
In fact I found one example in one of my apps:
```
<Button Style="{StaticResource BtnLeftMenuStyle}"
VerticalAlignment="Top"
ToolTip="Button tooltip"
Margin="0,0,0,10"
Command="{Binding UpdateCurrentViewCommand}"
CommandParameter="Planol">
<StackPanel Orientation="Vertical">
<Image Source="{StaticResource Planols}"
Style="{StaticResource ImgBtnMenuLateral}"/>
<TextBlock Text="Planol"
Style="{StaticResource TextBtnMenuLateral}"/>
</StackPanel>
</Button>
```
And this is my resource dictionary:
```
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Sysmac.Maquina">
<!-- Lateral menu -->
<BitmapImage x:Key="Home" UriSource="/Sysmac.Maquina;component/Assets/HomeBlue.png"/>
<BitmapImage x:Key="Produccio" UriSource="/Sysmac.Maquina;component/Assets/ProductionBlue.png"/>
<BitmapImage x:Key="Settings" UriSource="/Sysmac.Maquina;component/Assets/SettingsBlue.png"/>
<BitmapImage x:Key="Sortir" UriSource="/Sysmac.Maquina;component/Assets/PowerOffBlue.png"/>
<BitmapImage x:Key="Planols" UriSource="/Sysmac.Maquina;component/Assets/DesignBlue.png"/>
<BitmapImage x:Key="Crono" UriSource="/Sysmac.Maquina;component/Assets/CronoBlue.png"/>
<BitmapImage x:Key="Minimize" UriSource="/Sysmac.Maquina;component/Assets/MinimizeBlue.png"/>
<BitmapImage x:Key="Operari" UriSource="/Sysmac.Maquina;component/Assets/CustomerBlue.png"/>
<BitmapImage x:Key="Basura" UriSource="/Sysmac.Maquina;component/Assets/TrashBlue.png"/>
<!-- Logo -->
<BitmapImage x:Key="Logo" UriSource="/Sysmac.Maquina;component/Assets/AIS_Logo.png"/>
</ResourceDictionary>
```
Just remember to set:
Build action = Resource