【问题标题】:WPF - image doesn't show when program runs [duplicate]WPF - 程序运行时图像不显示[重复]
【发布时间】:2015-01-15 06:59:42
【问题描述】:

我有以下问题:我的 WPF 项目中包含了一个文件夹。 构建操作设置为:内容 复制到输出目录设置为:始终复制 文件夹名称:图片 我在我的 WPF .XAML 中使用了以下代码:

<Image Name="ImagesFolder" MouseWheel="ImagesFolder_MouseWheel" Width="320" Height="230"  Grid.Row="1" Margin="31,215,29,136">
    <Image.Source>
        <BitmapImage UriSource="Images/1.png"/>
    </Image.Source>
</Image>

图像显示在设计器窗口中,因此程序可以找到它,但是当我运行它时,我无法在它的位置看到图像。也尝试了 Canvas + Border 组合。另一方面,我有时会使用双面图片。因此,如果我有 5 张图片,如下所示:1,1_2,2,3,4 我希望程序在按钮单击事件上使用某种代码旋转我的图片。怎么做(每张图片背景将是前景的实际图片数量+前景的实际图片数量)?感谢您的帮助!

【问题讨论】:

    标签: c# wpf xaml


    【解决方案1】:

    您必须将 Build Action 设置为 'Resource' 并以以下格式指定源:'/Your.Assembly.Namespace;component/Images/1.png'

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-28
      • 2020-08-05
      • 2012-11-07
      相关资源
      最近更新 更多