VisualStudio 2017 "Blank App"
XAML
<Button x:Name="button" Content="Button1" HorizontalAlignment="Left" Margin="400,20,0,0" VerticalAlignment="Top" RenderTransformOrigin="-1.258,-5" Click="Button_Click" Height="80" Width="80"/>
C # (Set the original image in the properties of the button: right-click -> Brush -> image)
private void Button1_Click(object sender, RoutedEventArgs e) { button1.Background = new ImageBrush { ImageSource = new BitmapImage(new Uri("ms-appx:/Images/timerg.png", UriKind.RelativeOrAbsolute)) }; }
or C #
private void Button1_Click(object sender, RoutedEventArgs e) { BitmapImage bmp = new BitmapImage(); Uri u = new Uri("ms-appx:/Images/timer.png", UriKind.RelativeOrAbsolute); bmp.UriSource = u; // NOTE: change starts here Image i = new Image(); i.Source = bmp; button1.Content = i; }