【问题标题】:Image in button is rendering in the designer but not the windows phone emulator (Windows App Developement)按钮中的图像在设计器中呈现,而不是在 Windows Phone 模拟器中呈现(Windows 应用程序开发)
【发布时间】:2015-12-28 16:01:28
【问题描述】:

设计器将图像作为按钮加载,但模拟器加载时没有图像。我可以推测这可能是一个“超出屏幕的图像渲染”问题。任何有关代码的建议将不胜感激。

设计器完全可见,两个图像分割屏幕(假设是按钮),而模拟器显示一半屏幕为黑色,其余部分显示为灰色水平分割。

<Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height=".5*"/>
            <RowDefinition Height=".5*"/>
        </Grid.RowDefinitions>

        <Button 
            x:Name="CricketButton" Grid.Row="0"
            Height="auto" Width="auto"
            HorizontalAlignment="Stretch" 
            Margin="-5" VerticalAlignment="Stretch"  
            Click="CricketButton_Click"
            FontSize="25" RequestedTheme="Light" Opacity="0.9" BorderThickness="0">
                <Image Source="Assets\cricket-hd-wallpapers.jpg" Stretch="Fill" Opacity="0.7"/>
                <!--<TextBlock Text="Cricket" HorizontalAlignment="Right"  VerticalAlignment="Bottom"  Foreground="White" 
                           FontSize="72"/>-->
        </Button>

        <Button 
            x:Name="Football" Grid.Row="1"
            HorizontalAlignment="Stretch" 
            Height="auto" Width="auto"
            Margin="-5"
            VerticalAlignment="Stretch"
            Click="Football_Click"
            FontSize="25" 
            RequestedTheme="Light" Opacity="0.9" Background="#FFC7C7C7" BorderThickness="0">
                <Image Source="Assets\real-madrid-granada.jpg" Opacity="0.9" Stretch="Fill"/>
        </Button>
    </Grid>

【问题讨论】:

    标签: windows xaml emulation designer


    【解决方案1】:

    它可能无法在运行时解析文件位置。您需要确保将图像包含在构建中。

    http://www.wpfsharp.com/2012/01/23/using-relative-path-images-included-as-content-with-wpf/

    【讨论】:

    • 赞!我通过使用绑定和数据模型更改了源以在运行时接收字符串。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-14
    • 1970-01-01
    • 2013-01-05
    • 1970-01-01
    • 2018-08-20
    • 2012-10-14
    相关资源
    最近更新 更多