在我的Silverlight应用程序中,所有控件必须完全透明,以便可以看到背景图像。在我的实际工作中,我需要在DataGrid中显示数据。在阅读了解决DataGrid非透明标题问题的问题Change background color of Datagrid Header in Silverlight的答案之后,我仍然遇到DataGrid的ScrollViewer的标题中的备用将保持白色的问题,无论我应用于哪种样式ScrollViewer和ScrollBar。此外,水平ScrollBar保持白色。以下是我对ScrollBar和ScrollViewer的实际样式(例如,在列表框中,这就像魅力一样)。
<ControlTemplate x:Key="ScrollBarControlTemplate" TargetType="ScrollBar">
<Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
<Grid x:Name="Root">
<Grid x:Name="HorizontalRoot">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<RepeatButton x:Name="HorizontalSmallDecrease" Grid.Column="0" Interval="50" Style="{StaticResource RepeatButtonLineLeftStyle}" />
<RepeatButton x:Name="HorizontalLargeDecrease" Grid.Column="1" Interval="50" Style="{StaticResource RepeatButtonBlankStyle}" />
<Thumb x:Name="HorizontalThumb" Grid.Column="2" MinWidth="16" Style="{StaticResource ThumbHorizontalStyle}" />
<RepeatButton x:Name="HorizontalLargeIncrease" Grid.Column="3" Interval="50" Style="{StaticResource RepeatButtonBlankStyle}" />
<RepeatButton x:Name="HorizontalSmallIncrease" Grid.Column="4" Interval="50" Style="{StaticResource RepeatButtonLineRightStyle}" />
</Grid>
<Grid x:Name="VerticalRoot" Visibility="Collapsed">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<RepeatButton x:Name="VerticalSmallDecrease" Grid.Row="0" Interval="50" Style="{StaticResource RepeatButtonLineUpStyle}" />
<RepeatButton x:Name="VerticalLargeDecrease" Grid.Row="1" Interval="50" Style="{StaticResource RepeatButtonBlankStyle}" />
<Thumb x:Name="VerticalThumb" Grid.Row="2" MinHeight="16" Style="{StaticResource ThumbVerticalStyle}" />
<RepeatButton x:Name="VerticalLargeIncrease" Grid.Row="3" Interval="50" Style="{StaticResource RepeatButtonBlankStyle}" />
<RepeatButton x:Name="VerticalSmallIncrease" Grid.Row="4" Interval="50" Style="{StaticResource RepeatButtonLineDownStyle}" />
</Grid>
</Grid>
</Border>
</ControlTemplate>
<Style x:Key="ScrollBarStyle" TargetType="ScrollBar">
<Setter Property="MinWidth" Value="12" />
<Setter Property="MinHeight" Value="12" />
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="Template" Value="{StaticResource ScrollBarControlTemplate}" />
</Style>
<Style BasedOn="{StaticResource ScrollBarStyle}" TargetType="ScrollBar" />
<Style BasedOn="{StaticResource ScrollViewerStyle}" TargetType="ScrollViewer" />
我的想法已经用完了,也许有人可以帮助我!?
为了让您更清楚地了解我的问题,这就是目前的情况: