3

I am trying to create a very simple WPF application to experiment this concept of the Visual Studio Image Service and Catalog.

I don't understand why I cannot seem to be able to show any of the known images (using KnownMonikers) both on the WPF designer or when the app runs.

The image is there. It just does not show anything.

The image inside a border in the VS designer

enter image description here

Here's the WPF source code (following exactly the steps described in the MSDN link above):

<Window x:Class="ImageCatalogBrowser.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        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:local="clr-namespace:ImageCatalogBrowser"
        xmlns:imaging="clr-namespace:Microsoft.VisualStudio.Imaging;assembly=Microsoft.VisualStudio.Imaging"
        xmlns:theming="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Imaging"
        xmlns:utilities="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Utilities"
        xmlns:catalog="clr-namespace:Microsoft.VisualStudio.Imaging;assembly=Microsoft.VisualStudio.ImageCatalog"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <utilities:BrushToColorConverter x:Key="BrushToColorConverter"/>
    </Window.Resources>
    <Grid>
        <StackPanel
            Background="White"
            VerticalAlignment="Center"
            theming:ImageThemingUtilities.ImageBackgroundColor="{Binding Background, RelativeSource={RelativeSource Self}, Converter={StaticResource BrushToColorConverter}}">
            <Border BorderThickness="1" BorderBrush="Black" Width="33" Height="33">
                <imaging:CrispImage
                    x:Name="crisp"
                    Visibility="Visible"
                    Width="32"
                    Height="32"
                    Moniker="{x:Static catalog:KnownMonikers.Save}" />
            </Border>
        </StackPanel>
    </Grid>
</Window>

Can anyone help please?

  • Hi, I have same problem as you had. Did you clear the problem you mentioned above? Could you let me know how you cleared this problem. Thanks – Joon w K Jul 02 '18 at 08:18

1 Answers1

0

What's your code-behind doing to initialize the ImageLibrary? If the library cannot find the moniker you're requesting, then it won't display the image.

Make sure when initializing the ImageLibrary you give it the path to the ImageCatalog's .imagemanifest file (in the VS install dir).

Andrew
  • 1