【问题标题】:XAML - Button Image not showing up when I DebugXAML - 调试时未显示按钮图像
【发布时间】:2013-10-25 03:18:37
【问题描述】:

这是我的代码:

<Grid Background="Black">
    <Button Click="Button_Click" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <Image Source="Assets\Images\FlashOff.jpg"/>
    </Button>
</Grid>

按钮背景图像在 Visual Studio 中显示正常,但是当我调试时,图像不会显示。按钮的功能仍然存在。有什么想法吗?

【问题讨论】:

  • 我也在 Visual Studio 2012 中尝试过,但没有成功。有没有其他方法可以将按钮拉伸到网格并显示按钮?

标签: windows-8 windows-runtime microsoft-metro windows-store-apps winrt-xaml


【解决方案1】:

您需要使用正斜杠 (/) 而不是反斜杠 (\)。

<Grid Background="Black">
    <Button Click="Button_Click" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <Image Source="Assets/Images/FlashOff.jpg"/>
    </Button>
</Grid>

【讨论】:

  • 谢谢伙计。我已经习惯了文件夹路径,我什至没有想到这一点。
  • 仅供参考,当我移动一些图像时,resharper 添加了反斜杠。我愚蠢地期望它会做正确的事情并遇到了同样的问题。
猜你喜欢
  • 2021-10-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-02-16
相关资源
最近更新 更多