图像未在运行时显示

时间:2017-08-10 08:36:42

标签: c# xaml windows-phone

图像未在运行时显示。它正在设计器中显示。

  

XAML:

<ScrollViewer Grid.Row="1" Grid.Column="1">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="20"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Image Grid.Row="0" Source="/Assets/logo_108x108.png" Stretch="Fill" Width="400"  VerticalAlignment="Top" HorizontalAlignment="Center" Height="133" Grid.RowSpan="3" />
            <phone:WebBrowser x:Name="DescriptionBrowser"  Grid.Row="1" Grid.RowSpan="2"  Navigating="DescriptionBrowser_Navigating" Margin="0,149,0,0"/>            
            <TextBlock x:Name="ErrorBlock" Visibility="Collapsed" Foreground="Black" FontSize="20" Grid.Row="1" Grid.Column="1" Text="{Binding LocalizedResourcesFromCommonDll.ErrorGeneral, Source={StaticResource LocalizedCommonStrings}}" HorizontalAlignment="Center" VerticalAlignment="Center"  FontFamily="Segoe UI"/>
        </Grid>
    </ScrollViewer>
</Grid>

我尝试更换Image标签,但它仍无法正常工作。

1 个答案:

答案 0 :(得分:-1)

我尝试了建议的答案,它对我有用,并附有以下评论:

Resources目录与View位于同一级别,因此Source看起来像这样:Source="Resources/img.png"

此外,在图片的属性上,Build Action设置为Resource(默认情况下,您仍然可以检查)