我的Metro应用程序主页包含GridView。
<Page
x:Class="MyApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ReqWriter8"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" Loaded="Page_Loaded" >
<Page.Resources>
<!-- Collection of items displayed by this page -->
<CollectionViewSource x:Name="MyMenu" Source="{Binding}"></CollectionViewSource>
</Page.Resources>
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}" >
<!-- Horizontal scrolling grid -->
<GridView
x:Name="itemGridView"
AutomationProperties.AutomationId="ItemsGridView"
AutomationProperties.Name="Items"
TabIndex="1"
Grid.RowSpan="2"
Padding="116,136,116,46"
ItemsSource="{Binding Source={StaticResource MyMenu}}"
SelectionMode="None"
IsSwipeEnabled="false"
IsItemClickEnabled="True"
ItemClick="ItemView_ItemClick">
<GridView.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF1F4870" Offset="0"/>
<GradientStop Color="#FBA0B9D3" Offset="1"/>
</LinearGradientBrush>
</GridView.Background>
<GridView.ItemTemplate>
<DataTemplate >
<Grid HorizontalAlignment="Left" Width="250" Height="250" >
<Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}">
<Image Source="{Binding Image}" Stretch="UniformToFill" AutomationProperties.Name="{Binding Title}" />
</Border>
<StackPanel VerticalAlignment="Bottom" Background="Transparent" >
<TextBlock Text="{Binding Title}" Foreground="{StaticResource ListViewItemOverlayForegroundThemeBrush}" Style="{StaticResource GroupHeaderTextStyle}" Height="60" Margin="15,0,15,0" FontWeight="SemiBold"/>
<TextBlock Text="{Binding Description}" Foreground="{StaticResource ListViewItemOverlaySecondaryForegroundThemeBrush}" Style="{StaticResource GroupHeaderTextStyle}" TextWrapping="NoWrap" Margin="15,0,15,10" FontSize="12"/>
</StackPanel>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
这里的问题是PNG图像不透明(虽然当我在图片编辑器中打开它们时它们是透明的)
我知道有属性Window.AllowsTransparency = true属性,但它似乎不适用于Metro App。 那么我该如何解决这个问题?
答案 0 :(得分:0)
ItemTemplateis的边框背景使用 ListViewItemPlaceholderBackgroundThemeBrush 作为背景。
只需删除它,问题就会得到解决。
<Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}">
<Image Source="{Binding Image}" Stretch="UniformToFill" AutomationProperties.Name="{Binding Title}" />
</Border>