[SOLVED] How to set up the image source path properly in XAML


i’m trying to put a close button image on my newly created tabs for my app, but i just can’t seem to get the right path. This is how i’ve tried inputting it (code is from MainWindow.xaml):

<TabControl Margin="10,26,10,10" ItemsSource="{Binding FileTabs}">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding FileTabName}" />
                        <Button Name="closeTabBtn">
                            <Image Width="20" Height="20" Source="/Images/button-close.jpg" />

This is my project structure:

enter image description here

What is the correct path for the image source property since i’m kind of new at this ?


You should set the Build Action of the image file to Resource in Visual Studio and try with a pack URI if your relative path still doesn’t work:


Answered By – mm8

Answer Checked By – Cary Denson (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *