关于改变网格不透明度的内存

时间:2013-08-20 04:39:19

标签: xaml windows-phone-8

我有5个水平列表框,其中包含图像和文字..文本显示在stackpanel内的文本块中(背景为灰色)..现在如果我将背景更改为黑色并且不透明度为0.3,我开始得到outofmemory ..什么可能是错的?这是我的列表框:

<ScrollViewer x:Name="scroll1" HorizontalAlignment="Left" Height="200" Margin="0,27,0,0" VerticalAlignment="Top" Width="480" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled" >
<ListBox Name="firstList" Height="200" ScrollViewer.VerticalScrollBarVisibility="Disabled" Tap="firstList_SelectionChanged_1" >
<toolkit:GestureService.GestureListener>
    <toolkit:GestureListener DragCompleted="GestureListener_DragCompleted"></toolkit:GestureListener>
</toolkit:GestureService.GestureListener>
<ListBox.ItemsPanel>
    <ItemsPanelTemplate>
        <StackPanel Orientation="Horizontal" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Disabled" />
    </ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemContainerStyle>
    <Style TargetType="ListBoxItem">
        <Setter Property="Padding" Value="0 0 0 0 " />
    </Style>
</ListBox.ItemContainerStyle>

<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical" Height="200" Width="150" Background="Transparent">
    <!--Replace rectangle with image-->
    <Image Source="{Binding image}" Margin="0,20" HorizontalAlignment="Left" VerticalAlignment="Bottom" Stretch="UniformToFill" Height="140" Width="119"></Image>
    <Grid Margin="0,-335,0,0" HorizontalAlignment="Center" Background="Transparent" Height="30">
        <TextBlock Text="{Binding brandName}" HorizontalAlignment="Center" FontSize="15"  TextWrapping="NoWrap" Foreground="#FFAA1F17" />
    </Grid>
    <Grid Margin="70,-240,-10,0" Width="50" Height="50" Background="Transparent">
    <!--<TextBlock Text="Discount" Foreground="White" FontSize="15" Margin="15,0,5,0"/>-->
        <Image Source="{Binding imageSource}"  Width="50" Height="50" ></Image>
        <TextBlock Text="{Binding discountPercentage}" TextWrapping="NoWrap" HorizontalAlignment="Center" VerticalAlignment="Center"  Foreground="White" FontSize="15" />
    </Grid>
    <StackPanel Width="150" Margin="0,-35,0,0" Background="Transparent">

        <Grid HorizontalAlignment="Stretch" Height="55" Background="#FF9B9A9A">
         <!--<TextBlock Text="Rs" Foreground="White" FontSize="20" Margin="30,0,5,0"/>-->
            <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center" Background="Transparent">
                <TextBlock Text="{Binding productName}" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#99FFFFFF" FontSize="15" />
            </StackPanel>
        </Grid>

    </StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</ScrollViewer>

我已经尝试了这个并且出了很多错误:

<StackPanel Orientation="Vertical" Height="200" Width="150" Background="Transparent">
<!--Replace rectangle with image-->
<Image Source="{Binding image}" Margin="0,20" HorizontalAlignment="Left" VerticalAlignment="Bottom" Stretch="UniformToFill" Height="140" Width="119"></Image>
<Grid Margin="0,-335,0,0" HorizontalAlignment="Center" Background="Transparent" Height="30">
    <TextBlock Text="{Binding brandName}" HorizontalAlignment="Center" FontSize="15"  TextWrapping="NoWrap" Foreground="#FFAA1F17" />
</Grid>
<Grid Margin="70,-240,-10,0" Width="50" Height="50" Background="Transparent">
    <!--<TextBlock Text="Discount" Foreground="White" FontSize="15" Margin="15,0,5,0"/>-->
    <Image Source="{Binding imageSource}"  Width="50" Height="50" ></Image>
    <TextBlock Text="{Binding discountPercentage}" TextWrapping="NoWrap" HorizontalAlignment="Center" VerticalAlignment="Center"  Foreground="White" FontSize="15" />
</Grid>
<StackPanel Width="150" Margin="0,-35,0,0" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center" Background="Black" Opacity="0.3">

<TextBlock Text="{Binding productName}" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#99FFFFFF" FontSize="15" />

</StackPanel>
</StackPanel>

1 个答案:

答案 0 :(得分:0)

自我解决。用透明图像上的文本块替换grid / stackpanel。