图像问题-设计师展示-不运行应用程序-WPF
问题描述:
你好
我对图片有疑问
<Window x:Name="Okno" x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="773.388" Width="715.179">
<Grid HorizontalAlignment="Left" Height="744" VerticalAlignment="Top" Width="720" Margin="0,0,-277,-298">
<Image x:Name="a" Source="pack://application:,,,/Resources/1.jpg" HorizontalAlignment="Left" Height="336" Margin="152,198,0,0" VerticalAlignment="Top" Width="388"/>
</Grid>
</Window>
我使用了很多方法来做到这一点:
I used a lot of ways to do this:
Source="pack://application:,,,/Resources/1.jpg"
正确,但是不起作用.
在我的Visual Studio 2012设计器中,我看到了图像,但是当我运行应用程序时,它没有出现.
In my Visual Studio 2012 in designer i see the image but when i run app, it doesn't apear.
请帮助:]
答
请尝试删除控件的所有页边距.也尝试使用以下语法
Try remove all the margins for the controls. Also Try using below syntax
pack://application:,,/ReferencedAssembly; component/Subfolder/ResourceFile.xaml
http://msdn.microsoft.com/zh-cn/library/aa970069(v = vs.110).aspx
http://msdn.microsoft.com/en-us/library/aa970069(v=vs.110).aspx