2010-10-19 119 views
0

我有列表框,我需要設置背景「透明」。如何在列表框中設置屬性背景「透明」

alt text

我在紅已經選擇了,那麼就應該是透明的: alt text

風格的ListBox,ListBoxItem中,ScrollViewer中和滾動條:

<Style TargetType="{x:Type ScrollBar}"> 
    <Setter Property="Stylus.IsFlicksEnabled" Value="false"/> 
    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="{x:Type ScrollBar}"> 
       <Grid x:Name="GridRoot" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"> 
        <Grid.RowDefinitions> 
         <RowDefinition MaxHeight="18"/> 
         <RowDefinition Height="0.00001*"/> 
         <RowDefinition MaxHeight="18"/> 
        </Grid.RowDefinitions> 
        <Rectangle Grid.RowSpan="5" RadiusX="0" RadiusY="0" StrokeThickness="1" Stroke="#FFF0F0F0" Fill="#FFEFEFEF"/> 
        <RepeatButton x:Name="DecreaseRepeat" Style="{DynamicResource NuclearRepeatButton}" Command="ScrollBar.LineUpCommand"> 
         <Grid> 
          <Path x:Name="ArrowUp" Height="6" Width="10" Data="F1 M 541.537,173.589L 531.107,173.589L 536.322,167.49L 541.537,173.589 Z " HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="Uniform" IsHitTestVisible="False"> 
           <Path.Fill> 
            <LinearGradientBrush EndPoint="0.7,0.75" StartPoint="0.25,0"> 
             <GradientStop Color="#CC000000" Offset="0.25"/> 
             <GradientStop Color="#7F000000" Offset="0.75"/> 
             <GradientStop Color="#33000000" Offset="1"/> 
            </LinearGradientBrush> 
           </Path.Fill> 
          </Path> 
         </Grid> 
        </RepeatButton> 

        <Track Grid.Row="1" x:Name="PART_Track" Orientation="Vertical" IsDirectionReversed="true"> 
         <Track.Thumb> 
          <Thumb Style="{DynamicResource NuclearThumbStyle}"/> 
         </Track.Thumb> 
         <Track.IncreaseRepeatButton> 
          <RepeatButton x:Name="PageUp" Style="{DynamicResource NuclearScrollRepeatButtonStyle}" Command="ScrollBar.PageDownCommand"/> 
         </Track.IncreaseRepeatButton> 
         <Track.DecreaseRepeatButton> 
          <RepeatButton x:Name="PageDown" Style="{DynamicResource NuclearScrollRepeatButtonStyle}" Command="ScrollBar.PageUpCommand"/> 
         </Track.DecreaseRepeatButton> 
        </Track> 

        <RepeatButton Grid.Row="2" x:Name="IncreaseRepeat" Style="{DynamicResource NuclearRepeatButton}" Command="ScrollBar.LineDownCommand"> 
         <Grid> 
          <Path x:Name="ArrowDown" Grid.Row="4" Height="6" Width="10" Data="F1 M 531.107,321.943L 541.537,321.943L 536.322,328.042L 531.107,321.943 Z " HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="Uniform" IsHitTestVisible="False"> 
           <Path.Fill> 
            <LinearGradientBrush EndPoint="0.4,1" StartPoint="-0.3,0"> 
             <GradientStop Color="#CC000000" Offset="0.25"/> 
             <GradientStop Color="#7F000000" Offset="0.75"/> 
             <GradientStop Color="#33000000" Offset="1"/> 
            </LinearGradientBrush> 
           </Path.Fill> 
          </Path> 
         </Grid> 
        </RepeatButton> 
       </Grid> 

       <ControlTemplate.Triggers> 
        <Trigger Property="Orientation" Value="Horizontal"> 

         <Setter Property="LayoutTransform" TargetName="GridRoot"> 
          <Setter.Value> 
           <RotateTransform Angle="-90"/> 
          </Setter.Value> 
         </Setter> 

         <Setter TargetName="PART_Track" Property="Orientation" Value="Vertical"/> 

         <Setter Property="Command" Value="ScrollBar.LineLeftCommand" TargetName="DecreaseRepeat"/> 
         <Setter Property="Command" Value="ScrollBar.LineRightCommand" TargetName="IncreaseRepeat"/> 
         <Setter Property="Command" Value="ScrollBar.PageLeftCommand" TargetName="PageDown"/> 
         <Setter Property="Command" Value="ScrollBar.PageRightCommand" TargetName="PageUp"/> 
        </Trigger> 
       </ControlTemplate.Triggers> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 

<Style TargetType="{x:Type ScrollViewer}" BasedOn="{x:Null}"> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="{x:Type ScrollViewer}"> 
       <Grid Background="{TemplateBinding Background}"> 
        <Grid.ColumnDefinitions> 
         <ColumnDefinition Width="*"/> 
         <ColumnDefinition Width="Auto"/> 
        </Grid.ColumnDefinitions> 
        <Grid.RowDefinitions> 
         <RowDefinition Height="*"/> 
         <RowDefinition Height="Auto"/> 
        </Grid.RowDefinitions> 
        <ScrollContentPresenter Grid.Column="0" Grid.Row="0" Margin="{TemplateBinding Padding}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" CanContentScroll="{TemplateBinding CanContentScroll}"/> 

        <ScrollBar Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Grid.Column="0" Grid.Row="1" x:Name="PART_HorizontalScrollBar" Orientation="Horizontal" Value="{Binding Path=HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}" Minimum="0" Maximum="{TemplateBinding ScrollableWidth}" AutomationProperties.AutomationId="HorizontalScrollBar"/> 
        <ScrollBar Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Grid.Column="1" Grid.Row="0" x:Name="PART_VerticalScrollBar" Orientation="Vertical" Value="{Binding Path=VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}" Minimum="0" Maximum="{TemplateBinding ScrollableHeight}" AutomationProperties.AutomationId="VerticalScrollBar"/> 
       </Grid> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 


<!----> 
<ControlTemplate x:Key="ScrollViewerControlTemplate1" TargetType="{x:Type ScrollViewer}"> 
<Grid x:Name="Grid" Background="{TemplateBinding Background}"> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="*"/> 
    </Grid.ColumnDefinitions> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="*"/> 
    </Grid.RowDefinitions> 
    <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" Margin="{TemplateBinding Padding}" Grid.Column="0" Grid.Row="0" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False"/> 
    <ScrollBar x:Name="PART_HorizontalScrollBar" Cursor="Arrow" AutomationProperties.AutomationId="HorizontalScrollBar" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" Orientation="Horizontal" Style="{DynamicResource ScrollBarStyle1}" Height="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"/> 
</Grid> 
</ControlTemplate> 
<LinearGradientBrush x:Key="VerticalScrollBarBackground" EndPoint="1,0" StartPoint="0,0"> 
<GradientStop Color="#E1E1E1" Offset="0"/> 
<GradientStop Color="#EDEDED" Offset="0.20"/> 
<GradientStop Color="#EDEDED" Offset="0.80"/> 
<GradientStop Color="#E3E3E3" Offset="1"/> 
</LinearGradientBrush> 
<SolidColorBrush x:Key="ScrollBarDisabledBackground" Color="#FFFFFF"/> 
<Style x:Key="ScrollBarButton" TargetType="{x:Type RepeatButton}"> 
<Setter Property="OverridesDefaultStyle" Value="true"/> 
<Setter Property="Focusable" Value="false"/> 
<Setter Property="IsTabStop" Value="false"/> 
<Setter Property="Template"> 
    <Setter.Value> 
     <ControlTemplate TargetType="{x:Type RepeatButton}"> 
      <Microsoft_Windows_Themes:ScrollChrome x:Name="Chrome" SnapsToDevicePixels="true" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderPressed="{TemplateBinding IsPressed}" Microsoft_Windows_Themes:ScrollChrome.ScrollGlyph="{TemplateBinding Microsoft_Windows_Themes:ScrollChrome.ScrollGlyph}"/> 
     </ControlTemplate> 
    </Setter.Value> 
</Setter> 
</Style> 
<Style x:Key="VerticalScrollBarPageButton" TargetType="{x:Type RepeatButton}"> 
<Setter Property="OverridesDefaultStyle" Value="true"/> 
<Setter Property="Background" Value="Transparent"/> 
<Setter Property="Focusable" Value="false"/> 
<Setter Property="IsTabStop" Value="false"/> 
<Setter Property="Template"> 
    <Setter.Value> 
     <ControlTemplate TargetType="{x:Type RepeatButton}"> 
      <Rectangle Fill="{TemplateBinding Background}" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"/> 
     </ControlTemplate> 
    </Setter.Value> 
</Setter> 
</Style> 
<Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}"> 
<Setter Property="OverridesDefaultStyle" Value="true"/> 
<Setter Property="IsTabStop" Value="false"/> 
<Setter Property="Template"> 
    <Setter.Value> 
     <ControlTemplate TargetType="{x:Type Thumb}"> 
      <Microsoft_Windows_Themes:ScrollChrome x:Name="Chrome" SnapsToDevicePixels="true" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderPressed="{TemplateBinding IsDragging}" Microsoft_Windows_Themes:ScrollChrome.ScrollGlyph="{TemplateBinding Microsoft_Windows_Themes:ScrollChrome.ScrollGlyph}"/> 
     </ControlTemplate> 
    </Setter.Value> 
</Setter> 
</Style> 
<LinearGradientBrush x:Key="HorizontalScrollBarBackground" EndPoint="0,1" StartPoint="0,0"> 
<GradientStop Color="#E1E1E1" Offset="0"/> 
<GradientStop Color="#EDEDED" Offset="0.20"/> 
<GradientStop Color="#EDEDED" Offset="0.80"/> 
<GradientStop Color="#E3E3E3" Offset="1"/> 
</LinearGradientBrush> 
<Style x:Key="HorizontalScrollBarPageButton" TargetType="{x:Type RepeatButton}"> 
<Setter Property="OverridesDefaultStyle" Value="true"/> 
<Setter Property="Background" Value="Transparent"/> 
<Setter Property="Focusable" Value="false"/> 
<Setter Property="IsTabStop" Value="false"/> 
<Setter Property="Template"> 
    <Setter.Value> 
     <ControlTemplate TargetType="{x:Type RepeatButton}"> 
      <Rectangle Fill="{TemplateBinding Background}" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"/> 
     </ControlTemplate> 
    </Setter.Value> 
</Setter> 
</Style> 
<Style x:Key="ScrollBarStyle1" TargetType="{x:Type ScrollBar}"> 
<Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/> 
<Setter Property="Stylus.IsFlicksEnabled" Value="false"/> 
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/> 
<Setter Property="Width" Value="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"/> 
<Setter Property="MinWidth" Value="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"/> 
<Setter Property="Template"> 
    <Setter.Value> 
     <ControlTemplate TargetType="{x:Type ScrollBar}"> 
      <Grid x:Name="Bg" SnapsToDevicePixels="true" Background="{TemplateBinding Background}"> 
       <Grid.RowDefinitions> 
        <RowDefinition MaxHeight="{DynamicResource {x:Static SystemParameters.VerticalScrollBarButtonHeightKey}}"/> 
        <RowDefinition Height="0.00001*"/> 
        <RowDefinition MaxHeight="{DynamicResource {x:Static SystemParameters.VerticalScrollBarButtonHeightKey}}"/> 
       </Grid.RowDefinitions> 
       <RepeatButton Style="{StaticResource ScrollBarButton}" IsEnabled="{TemplateBinding IsMouseOver}" Microsoft_Windows_Themes:ScrollChrome.ScrollGlyph="UpArrow" Command="{x:Static ScrollBar.LineUpCommand}"/> 
       <Track x:Name="PART_Track" IsEnabled="{TemplateBinding IsMouseOver}" Grid.Row="1" IsDirectionReversed="true"> 
        <Track.DecreaseRepeatButton> 
         <RepeatButton Style="{StaticResource VerticalScrollBarPageButton}" Command="{x:Static ScrollBar.PageUpCommand}"/> 
        </Track.DecreaseRepeatButton> 
        <Track.IncreaseRepeatButton> 
         <RepeatButton Style="{StaticResource VerticalScrollBarPageButton}" Command="{x:Static ScrollBar.PageDownCommand}"/> 
        </Track.IncreaseRepeatButton> 
        <Track.Thumb> 
         <Thumb Style="{StaticResource ScrollBarThumb}" Microsoft_Windows_Themes:ScrollChrome.ScrollGlyph="VerticalGripper"/> 
        </Track.Thumb> 
       </Track> 
       <RepeatButton Style="{StaticResource ScrollBarButton}" IsEnabled="{TemplateBinding IsMouseOver}" Grid.Row="2" Microsoft_Windows_Themes:ScrollChrome.ScrollGlyph="DownArrow" Command="{x:Static ScrollBar.LineDownCommand}"/> 
      </Grid> 
      <ControlTemplate.Triggers> 
       <Trigger Property="IsEnabled" Value="false"> 
        <Setter Property="Background" TargetName="Bg" Value="{StaticResource ScrollBarDisabledBackground}"/> 
       </Trigger> 
      </ControlTemplate.Triggers> 
     </ControlTemplate> 
    </Setter.Value> 
</Setter> 
<Style.Triggers> 
    <Trigger Property="Orientation" Value="Horizontal"> 
     <Setter Property="Width" Value="Auto"/> 
     <Setter Property="MinWidth" Value="0"/> 
     <Setter Property="Height" Value="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}"/> 
     <Setter Property="MinHeight" Value="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}"/> 
     <Setter Property="Background" Value="{StaticResource HorizontalScrollBarBackground}"/> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="{x:Type ScrollBar}"> 
        <Grid x:Name="Bg" SnapsToDevicePixels="true" VerticalAlignment="Stretch"> 
         <Grid.RowDefinitions> 
          <RowDefinition/> 
         </Grid.RowDefinitions> 
         <Grid.ColumnDefinitions> 
          <ColumnDefinition MaxWidth="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}}"/> 
          <ColumnDefinition Width="0.00001*"/> 
          <ColumnDefinition MaxWidth="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}}"/> 
         </Grid.ColumnDefinitions> 
         <RepeatButton Style="{StaticResource ScrollBarButton}" Microsoft_Windows_Themes:ScrollChrome.ScrollGlyph="LeftArrow" Command="{x:Static ScrollBar.LineLeftCommand}" Background="#FFEB0707"/> 
         <RepeatButton Style="{StaticResource ScrollBarButton}" Grid.Column="2" Microsoft_Windows_Themes:ScrollChrome.ScrollGlyph="RightArrow" Command="{x:Static ScrollBar.LineRightCommand}"/> 
        </Grid> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Trigger> 
</Style.Triggers> 
</Style> 
<!----> 






<Style TargetType="{x:Type ListBox}"> 
    <Setter Property="SnapsToDevicePixels" Value="true"/> 
    <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/> 
    <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/> 
    <Setter Property="ScrollViewer.CanContentScroll" Value="True"/> 
    <Setter Property="HorizontalContentAlignment" Value="Stretch" /> 
    <Setter Property="VerticalContentAlignment" Value="Center" /> 
    <Setter Property="BorderBrush" Value="{StaticResource btnPressStroke2}"/> 
    <Setter Property="BorderThickness" Value="1"/> 
    <Setter Property="Padding" Value="1"/> 
    <Setter Property="Foreground" Value="{StaticResource OutsideFontColor}"/> 
    <Setter Property="Background" Value="Transparent"/> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="{x:Type ListBox}"> 
       <Grid> 
        <Border BorderThickness="{TemplateBinding BorderThickness}" Background="#FFFFFFFF" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="2"> 
         <ScrollViewer Template="{StaticResource ScrollViewerControlTemplate1}" Margin="1" Focusable="false" Background="Transparent"> 
          <WrapPanel Margin="2" IsItemsHost="True" /> 
         </ScrollViewer> 
        </Border> 
       </Grid> 
       <ControlTemplate.Triggers> 
        <Trigger Property="IsEnabled" Value="false"/> 
        <Trigger Property="IsGrouping" Value="true"> 
         <Setter Property="ScrollViewer.CanContentScroll" Value="false"/> 
        </Trigger> 
       </ControlTemplate.Triggers> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 


<Style d:IsControlPart="True" TargetType="{x:Type ListBoxItem}"> 
    <Setter Property="SnapsToDevicePixels" Value="true"/> 
    <Setter Property="OverridesDefaultStyle" Value="true"/> 
    <Setter Property="HorizontalContentAlignment" Value="Stretch" /> 
    <Setter Property="VerticalContentAlignment" Value="Center" /> 
    <Setter Property="Padding" Value="3" /> 
    <Setter Property="Foreground" Value="{StaticResource OutsideFontColor}"/> 
    <Setter Property="Background" Value="Transparent"/> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="{x:Type ListBoxItem}"> 
       <ControlTemplate.Resources> 
        <Storyboard x:Key="HoverOn"> 
         <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundGradientOver" Storyboard.TargetProperty="Opacity" To="0.73"/> 
        </Storyboard> 
        <Storyboard x:Key="HoverOff"> 
         <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundGradientOver" Storyboard.TargetProperty="Opacity" To="0"/> 
        </Storyboard> 
        <Storyboard x:Key="SelectedOn"> 
         <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundGradientSelected" Storyboard.TargetProperty="Opacity" To="0.84"/> 
         <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundGradientSelectedDisabled" Storyboard.TargetProperty="Opacity" To="1"/> 
        </Storyboard> 
        <Storyboard x:Key="SelectedOff"> 
         <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundGradientSelected" Storyboard.TargetProperty="Opacity" To="0"/> 
         <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundGradientSelectedDisabled" Storyboard.TargetProperty="Opacity" To="0"/> 
        </Storyboard> 
       </ControlTemplate.Resources> 
       <Grid SnapsToDevicePixels="true"> 
        <Rectangle x:Name="BackgroundGradientOver" Fill="{StaticResource hoverGradient}" Stroke="{StaticResource hoverStroke}" RadiusX="2" RadiusY="2" Opacity="0"/> 
        <Rectangle x:Name="BackgroundGradientSelectedDisabled" Fill="{StaticResource grayGradient}" Stroke="#7F8E8F8F" RadiusX="2" RadiusY="2" Opacity="0"/> 
        <Rectangle x:Name="BackgroundGradientSelected" Fill="{StaticResource BtnOverFill}" Stroke="{StaticResource selectedStroke}" RadiusX="2" RadiusY="2" Opacity="0"/> 
        <Rectangle x:Name="BackgroundHighlight" Margin="1" Stroke="#A0FFFFFF" RadiusX="1" RadiusY="1"/> 
        <ContentPresenter 
        x:Name="contentPresenter" 
        Content="{TemplateBinding Content}" 
        ContentTemplate="{TemplateBinding ContentTemplate}" 
        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
        Margin="{TemplateBinding Padding}"/> 
       </Grid> 
       <ControlTemplate.Triggers> 

        <Trigger Property="IsSelected" Value="true"> 
         <Trigger.ExitActions> 
          <BeginStoryboard Storyboard="{StaticResource SelectedOff}" x:Name="SelectedOff_BeginStoryboard"/> 
         </Trigger.ExitActions> 
         <Trigger.EnterActions> 
          <BeginStoryboard Storyboard="{StaticResource SelectedOn}" x:Name="SelectedOn_BeginStoryboard"/> 
         </Trigger.EnterActions> 

        </Trigger> 
        <Trigger Property="IsMouseOver" Value="True"> 
         <Trigger.ExitActions> 
          <BeginStoryboard Storyboard="{StaticResource HoverOff}" x:Name="HoverOff_BeginStoryboard"/> 
         </Trigger.ExitActions> 
         <Trigger.EnterActions> 
          <BeginStoryboard Storyboard="{StaticResource HoverOn}"/> 
         </Trigger.EnterActions> 
        </Trigger> 

        <Trigger Property="IsEnabled" Value="false"> 
         <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/> 
         <Setter Property="Visibility" TargetName="BackgroundGradientSelected" Value="Hidden"/> 
        </Trigger> 
       </ControlTemplate.Triggers> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 

<Style x:Key="ExpanderHeaderFocusVisual"> 
    <Setter Property="Control.Template"> 
     <Setter.Value> 
      <ControlTemplate> 
       <Border> 
        <Rectangle SnapsToDevicePixels="true" Margin="0" Stroke="Black" StrokeDashArray="1 2" StrokeThickness="1" /> 
       </Border> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 

列表框在XAML:

<ListBox Grid.Row="2" x:Name="list_category" Background="Transparent" ItemsSource="{Binding Tables[0]}" VerticalContentAlignment="Stretch" > 
    <ListBox.Resources> 
     <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"/> 
     <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black"/> 
     <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="#00FFFFFF"/> 
    </ListBox.Resources> 
    <ListBox.ItemTemplate> 
     <DataTemplate> 
      <GroupBox Header="Сопровождающие" Width="300" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch" HorizontalAlignment="Stretch" x:Name="GroupBox" Background="Transparent"> 
       <DockPanel Tag="{Binding id_Person}" VerticalAlignment="Stretch"> 
        <Button Click="Button_Click" DockPanel.Dock="Top"> 
         <Button.Content> 
          <DockPanel VerticalAlignment="Stretch"> 
           <StackPanel DockPanel.Dock="Top" Orientation="Horizontal" HorizontalAlignment="Center"> 
            <TextBlock Text="{Binding surname}" Padding="5" HorizontalAlignment="Center" Foreground="#FFB51414" /> 
            <TextBlock Text="{Binding name}" Padding="5" HorizontalAlignment="Center" Foreground="#FFB51414" /> 
            <TextBlock Text="{Binding lastname}" Padding="5" HorizontalAlignment="Center" Foreground="#FFB51414" /> 
           </StackPanel> 
           <Grid DockPanel.Dock="Bottom"> 
            <Grid.RowDefinitions> 
             <RowDefinition /> 
             <RowDefinition /> 
            </Grid.RowDefinitions> 
            <Grid.ColumnDefinitions> 
             <ColumnDefinition /> 
             <ColumnDefinition /> 
             <ColumnDefinition /> 
             <ColumnDefinition /> 
             <ColumnDefinition /> 
            </Grid.ColumnDefinitions> 

            <TextBlock Text="{Binding quarter}" x:Name="quarter" Padding="5" Grid.Column="2" Grid.Row="1" HorizontalAlignment="Center" Foreground="#FFB51414" /> 
            <TextBlock Text="{Binding halfyear}" x:Name="halfyear" Padding="5" Grid.Column="3" Grid.Row="1" HorizontalAlignment="Center" Foreground="#FFB51414" /> 
            <TextBlock Text="{Binding year}" x:Name="year" Padding="5" Grid.Column="4" Grid.Row="1" HorizontalAlignment="Center" Foreground="#FFB51414" /> 

            <TextBlock Text="Период: " Padding="5" Grid.Column="1" HorizontalAlignment="Center" Foreground="#FFB51414" /> 

            <TextBlock Text="Квартал" Padding="5" Grid.Column="2" HorizontalAlignment="Center" Foreground="#FFB51414" /> 
            <TextBlock Text="Полгода" Padding="5" Grid.Column="3" HorizontalAlignment="Center" Foreground="#FFB51414" /> 
            <TextBlock Text="Год" Padding="5" Grid.Column="4" HorizontalAlignment="Center" Foreground="#FFB51414" /> 
            <TextBlock Text="Цена: " Padding="5" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Center" Foreground="#FFB51414" /> 
           </Grid> 


           <Grid DockPanel.Dock="Top" MinHeight="180" MaxHeight="180"> 
            <Image Source="{Binding photo}"/> 
           </Grid> 
          </DockPanel> 
         </Button.Content> 
        </Button> 
        <Button DockPanel.Dock="Bottom" x:Name="send_mess" Tag="{Binding id_Person}" Click="send_mess_Click" Content="Написать сопровождающему"/> 
        <DockPanel DockPanel.Dock="Bottom" HorizontalAlignment="Center" Tag="{Binding id_Person}" > 
         <ComboBox VerticalAlignment="Top" x:Name="combobox_term"> 
          <ComboBoxItem Content="Квартал" Tag="1"/> 
          <ComboBoxItem Content="Полгода" Tag="2"/> 
          <ComboBoxItem Content="Год" Tag="3" IsSelected="True"/> 
         </ComboBox> 
         <CheckBox Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked" IsChecked="{Binding id_Person, Converter={StaticResource CheckBoxToCheked}}" Content="Выбрать" /> 
        </DockPanel> 

       </DockPanel> 
      </GroupBox> 
     </DataTemplate> 
    </ListBox.ItemTemplate> 
</ListBox> 
+0

你想要的項目的背景顏色是透明的?或者項目和列表框背景 – TerrorAustralis 2010-10-19 22:01:37

+0

不,項目不應該是透明的 – Mediator 2010-10-19 22:06:26

回答

1

在你的控制模板,你有一個聲明說

<Border ... Background="#FFFFFFFF">... 

因爲這並不inherrit風格的背景,你是硬編碼爲您的列表框的背景。

嘗試改變,要Background={TemplateBinding Background}

注:

它在列表框的默認樣式...完整的語句是

<Border BorderThickness="{TemplateBinding BorderThickness}" Background="#FFFFFFFF" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="2"> 
    <ScrollViewer Template="{StaticResource ScrollViewerControlTemplate1}" Margin="1" Focusable="false" Background="Transparent"> 
     <WrapPanel Margin="2" IsItemsHost="True" /> 
    </ScrollViewer> 
</Border> 
+0

它只是不默認樣式 – Mediator 2010-10-19 22:13:24

+0

已編輯的答案我認爲問題在於你的默認樣式 – TerrorAustralis 2010-10-19 22:21:50

+0

tip top =)very well =)謝謝 – Mediator 2010-10-19 22:24:19