WPF AreaSeries:如何更改背景不透明度?

时间:2013-05-27 11:14:33

标签: .net wpf vb.net charts

我正在使用WPF Toolkit中的AreaSeries来实现堆叠区域之类的东西。 但是这对于WPF工具包来说实际上是不可能的,所以我将简单地绘制两个系列,而后面的那个是前系列和“堆叠”系列的总和。 因此该系列的不透明度应为100%。但是虽然我将每个可能的不透明度设置为1.0,但该系列仍然有点透明。 那么,有谁知道,秘密转换在哪里?

这是一个片段,因此您可以看到我已经设置了不透明度的位置,但没有效果......

Dim col As System.Windows.Media.Color
col = System.Windows.Media.ColorConverter.ConvertFromString("#ff00ff00")
Dim brush As System.Windows.Media.Brush = New SolidColorBrush(col)
brush.Opacity = 1.0
series.Background = brush
series.Opacity = 1.0
series.Background.Opacity = 1.0

1 个答案:

答案 0 :(得分:1)

  <ch:Chart Margin="56,21,50,72" Title="MyChart" DataContext="{Binding ElementName=Window, Mode=OneWay}"  Style="{StaticResource controlStyle}" >

                    <ch:AreaSeries Name="DefaultArea" ItemsSource="{Binding Path=Key}" IndependentValueBinding="{Binding Key}" DependentValueBinding="{Binding Value}" Opacity="1" Title="111111" >
                        <ch:AreaSeries.Style>
                            <Style TargetType="ch:AreaSeries">
                                <Setter Property="IsTabStop" Value="False"/>
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="ch:AreaSeries">
                                            <Canvas x:Name="PlotArea">
                                                <Path Data="{TemplateBinding Geometry}" StrokeThickness="3" Fill="Pink" Style="{TemplateBinding PathStyle}" Opacity="1" />
                                            </Canvas>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </ch:AreaSeries.Style>
                    </ch:AreaSeries>

                    <ch:AreaSeries Name="PersonnelArea" ItemsSource="{Binding Path=Key}" IndependentValueBinding="{Binding Key}" DependentValueBinding="{Binding Value}" Opacity="1" >
                        <ch:AreaSeries.Style>
                            <Style TargetType="ch:AreaSeries">
                                <Setter Property="IsTabStop" Value="False"/>
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="ch:AreaSeries">
                                            <Canvas x:Name="PlotArea">
                                                <Path Data="{TemplateBinding Geometry}" StrokeThickness="3" Fill="Yellow" Style="{TemplateBinding PathStyle}" Opacity="1" />
                                            </Canvas>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </ch:AreaSeries.Style>

                    </ch:AreaSeries>  
                </ch:Chart>