This is the syntax of xaml. You could refer to the XAML overview in WPF and the Code-Behind and XAML in WPF.
The Image.Source Property is of the ImageSource
type and uses the following method in Codebehind.
image1.Source= new BitmapImage(new Uri("li.png", UriKind.Relative));
Sample:
<StackPanel>
<Image x:Name="image" Source="li.png " Width="200" Height="200"/>
<Image x:Name="image1" Width="200" Height="200"/>
</StackPanel>
Codebehind:
public MainWindow()
{
InitializeComponent();
image1.Source= new BitmapImage(new Uri("li.png", UriKind.Relative));
}
The result:
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.