网格背景图像不透明度问题

时间:2012-10-26 15:15:30

标签: c# windows-phone-7

我对网格布局的背景图片有一个奇怪的问题。由于某种原因,ListPicker没有完全覆盖图像。相反,应用了一些不透明度......(查看图片中的齿轮图标)

Gird background with opacity issue

 <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <Grid>
            <Grid.Background>
                <ImageBrush 
                        ImageSource="/BrewingApp;component/Images/icon_gears_big.png" 
                        AlignmentX="Right" 
                        AlignmentY="Bottom" 
                        Stretch="None" 
                        Opacity="0.5" />
            </Grid.Background>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="1*"/>
            </Grid.RowDefinitions>
...
                <StackPanel
                Grid.Row="1"
                Margin="0,12,0,0">
                <TextBlock Text="More Stuff :-)"></TextBlock>
                <Rectangle
                        Grid.Row="1"
                        HorizontalAlignment="Stretch"
                        VerticalAlignment="Top"
                        Height="1" 
                        Stroke="Red" 
                        StrokeThickness="1" >
                </Rectangle>

                <toolkit:ListPicker
                    Header="Hop Formula"
                    ItemsSource="{Binding HopFormulaList}"
                    SelectedItem="{Binding HopFormulaSelection, Mode=TwoWay}"
                    HorizontalAlignment="Stretch" OpacityMask="Blue" />

            </StackPanel>

        </Grid>

谢谢!

1 个答案:

答案 0 :(得分:1)

TextBoxListPicker正在使用PhoneTextBoxBrush作为背景。此画笔使用颜色#BFFFFFFF。即,具有一点透明度(BF)的白色(FFFFFF)。因此你的问题。解决问题的一种方法是简单地改变这些控件的背景:

<Grid.Resources>
    <SolidColorBrush x:Key="PhoneTextBoxBrush" Color="#BEBEBE"/>
    <Style TargetType="toolkit:ListPicker">
        <Setter Property="Background" Value="{StaticResource PhoneTextBoxBrush}" />
    </Style>
    <Style TargetType="TextBox">
        <Setter Property="Background" Value="{StaticResource PhoneTextBoxBrush}" />
    </Style>
</Grid.Resources>