我在XAML for Windows Phone 8中定义了以下页面
<phone:PhoneApplicationPage x:Class="MangaRack.View.Phone.View.ChapterView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
shell:SystemTray.IsVisible="False">
<Grid Background="White">
<Button BorderThickness="0" Name="ImageButton" Padding="0">
<Image Name="Image" />
</Button>
</Grid>
</phone:PhoneApplicationPage>网格定义了一个适用于整个屏幕的白色背景,但是网格的内容并不靠近窗口的边缘,在图像和窗口边缘之间有一个可观察的边缘/填充。如何确保图像直接针对窗口边缘
发布于 2013-03-13 13:31:24
尝试设置您的图像Stretch属性:
<Image Name="Image" Stretch="UniformToFill"/>有关更多信息,请参见关于图像拉伸的MSDN页面。
此外,您的按钮将添加一些‘填充’围绕您的形象。为了避免这种情况,您必须更改它的模板。我将把模板替换为只呈现内容的模板:
<Button>
<Button.Template>
<ControlTemplate TargetType="Button">
<StackPanel x:Name="stackPanel" Orientation="Horizontal">
<ContentPresenter VerticalAlignment="Bottom"/>
</StackPanel>
</ControlTemplate>
</Button.Template>
<Image Name="Image" Stretch="UniformToFill"/>
</Button>虽然,如果您要完全删除按钮“铬”,您可以直接使用图像,并处理点击/点击图片上的事件。
发布于 2013-03-25 13:53:30
您可以将图像放置在网格中,以便将其显示在全屏上,这是C#编码。
System.Windows.Media.ImageBrush myBrush = new System.Windows.Media.ImageBrush();
Image image = new Image();
image.ImageFailed += (s, i) => MessageBox.Show("Failed to load: " + i.ErrorException.Message);
image.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(@"/Assets/bg/bg5.jpg/", UriKind.RelativeOrAbsolute));
myBrush.ImageSource = image.Source;
grid1.Background = myBrush;https://stackoverflow.com/questions/15386700
复制相似问题