ArcGIS Pro Add-In XAML: Image not displaying

862
2
Jump to solution
01-15-2022 03:50 AM
JadedEarth
Occasional Contributor

I added a ProWindow in my Add-In.  Then I added 2 rows.  On the Grid.Row="0", I added an image tag:

<Image Margin="197,21,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Height="60" Width="60" Source="swat256.png" Visibility="Visible" Grid.Row="0"/>

But when I ran my add-in the ProWindow displays WITHOUT showing the image.

What am I doing wrong?  XAML code:

<controls:ProWindow x:Class="SWAT_.SwatWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:controls="clr-namespace:ArcGIS.Desktop.Framework.Controls;assembly=ArcGIS.Desktop.Framework"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:extensions="clr-namespace:ArcGIS.Desktop.Extensions;assembly=ArcGIS.Desktop.Extensions"
        mc:Ignorable="d"
        Title="SWAT+ SQL Server Tools  v.1.0.0" Height="400" Width="500"
        WindowStartupLocation="CenterOwner" FontFamily="Segoe UI" 
    >
    <controls:ProWindow.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <!--<extensions:DesignOnlyResourceDictionary Source="pack://application:,,,/ArcGIS.Desktop.Framework;component\Themes\Default.xaml"/>-->
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </controls:ProWindow.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="96*"/>
            <RowDefinition Height="275*"/>
        </Grid.RowDefinitions>

        <Image Margin="197,21,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Height="60"  Width="60" Source="swat256.png" Visibility="Visible" Grid.Row="0"/>
        <Button x:Name="BtnSqlConnect" Content="Create SQL Server Database Connection" HorizontalAlignment="Center" Margin="130,51,134.333,0" VerticalAlignment="Top" Height="21" Width="229" Click="BtnSqlConnect_Click" Grid.Row="1"/>
        <Button x:Name="BtnReset" Content="Initialize Tables" HorizontalAlignment="Center" Margin="128,96,134.333,0" VerticalAlignment="Top" Height="21" Width="231" Click="BtnDropTables_Click" Grid.Row="1"/>
        <Button x:Name="BtnClose" Content="Close" HorizontalAlignment="Left" Margin="206,223,0,0" VerticalAlignment="Top" Height="23" Width="75" Click="BtnClose_Click" Grid.Row="1"/>
        
    </Grid>
</controls:ProWindow>

 

Appreciate any help.

0 Kudos
1 Solution

Accepted Solutions
GKmieliauskas
Esri Regular Contributor

Hi,

1. Check image properties in Visual Studio. "Build Action" must be set to "Resource".

2. Check image location in project. From your code it must be in the root of project. Maybe it in the "Images" folder.

3. Sometimes helps another way of image location defining:

<Image Source="/your_addin_name;component/your_image_relative_path" />

View solution in original post

2 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

1. Check image properties in Visual Studio. "Build Action" must be set to "Resource".

2. Check image location in project. From your code it must be in the root of project. Maybe it in the "Images" folder.

3. Sometimes helps another way of image location defining:

<Image Source="/your_addin_name;component/your_image_relative_path" />
JadedEarth
Occasional Contributor

AWESOME!!! Thanks!

0 Kudos