Xaml 关于更改栅格不透明度的outofmemory

Xaml 关于更改栅格不透明度的outofmemory,xaml,windows-phone-8,Xaml,Windows Phone 8,我有5个水平列表框,其中包含图像和文本。。文本以灰色显示在StackPanel背景内的textblock中。。现在,如果我将背景更改为黑色,不透明度更改为0.3,我将开始退出内存。。有什么不对吗??这是我的列表框: <ScrollViewer x:Name="scroll1" HorizontalAlignment="Left" Height="200" Margin="0,27,0,0" VerticalAlignment="Top" Width="480" HorizontalScro

我有5个水平列表框,其中包含图像和文本。。文本以灰色显示在StackPanel背景内的textblock中。。现在,如果我将背景更改为黑色,不透明度更改为0.3,我将开始退出内存。。有什么不对吗??这是我的列表框:

<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>

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

您的代码隐藏将非常有助于诊断OOM异常。您是否可以发布此XAML的代码隐藏,以及它所指的内容?您正在使用Windows Phone Toolkit还是什么?另外,请告诉我们异常的消息是什么。另外,当我在没有代码隐藏的情况下运行此代码时,它没有给出任何异常。我通过在透明图像上用文本块替换grid/stackpanel解决了此问题。谢谢..你还需要帮助吗??