为什么这个Microsoft.VisualStudio.Imaging.CrispImage没有显示任何内容?

3

我正在尝试创建一个非常简单的WPF应用程序,以实验Visual StudioImage Service和Catalog的概念。

我不明白为什么似乎无法显示任何已知图像(使用KnownMonikers)在WPF设计器上或应用程序运行时。

图片在那里。它只是没有显示出来。

The image inside a border in the VS designer

enter image description here

这是WPF源代码(完全按照上面MSDN链接中描述的步骤):

<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>

有人可以帮忙吗?


嗨,我遇到了与你相同的问题。你解决了上面提到的问题吗?你能告诉我你是如何解决这个问题的吗?谢谢。 - Joon w K
1个回答

0
你的代码后台在初始化ImageLibrary时做了什么?如果库无法找到你请求的标识符,则不会显示图像。
确保在初始化ImageLibrary时,将其路径指定为ImageCatalog的.imagemanifest文件(在VS安装目录中)。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接