2012-10-26 41 views
1

我有一個網格佈局的背景圖像奇怪的問題。出於某種原因,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> 

謝謝!

+0

是什麼'OpacityMask =「藍」'指什麼? – paul

+0

對不起,我開始玩一些不同的值......我並不是真的想要使用OpacityMask。我想我只是忘了刪除它! – Tom

回答

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

幾乎完美,控件的邊框仍然是透明的。你知道邊界的顏色和屬性嗎? thx – Tom

+1

只需檢查ListPicker的源代碼:http://silverlight.codeplex.com/SourceControl/changeset/view/80285#1510300''。然後檢查默認的WP7主題以查看畫筆的默認值('C:\ Program Files(x86)\ Microsoft SDKs \ Windows Phone \ v7.1 \ Design \ ThemeResources.xaml')。在這種情況下,它使用與背景相同的畫筆,因此''Setter Property =「BorderBrush」Value =「{StaticResource PhoneTextBoxBrush}」/>'應該能夠做到這一點。 –