WPF图表图例

4

我该如何放大这些矩形?我正在使用wpf工具包中的图表,尝试过调整控制图例大小,但没有帮助。

alt text

1个回答

7

使用Blend,在对象面板中:
右键单击[PieSeries]
-编辑其他模板
-编辑LegendItemStyle
-编辑副本

您应该会得到一个默认样式:

<Style x:Key="PieChartLegendItemStyle" TargetType="{x:Type chartingToolkit:LegendItem}">
    <Setter Property="IsTabStop" Value="False" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type chartingToolkit:LegendItem}">
                <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                    <StackPanel Orientation="Horizontal">
                        <Rectangle Width="8" Height="8" Fill="{Binding Background}" Stroke="{Binding BorderBrush}" StrokeThickness="1" Margin="0,0,3,0" />
                        <visualizationToolkit:Title Content="{TemplateBinding Content}" />
                    </StackPanel>
                </Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style> 

你的控件将获得一个LegendItemStyle

<Charting:PieSeries ItemsSource="{Binding PutYourBindingHere}" 
                                    IndependentValueBinding="{Binding Key}" DependentValueBinding="{Binding Value}" IsSelectionEnabled="True" LegendItemStyle="{DynamicResource PieChartLegendItemStyle}">

好的,可视化工具包命名空间是从哪里来的? - Mitulát báti
很抱歉:我不记得了,已经很久以前了。这在很大程度上取决于您如何实现工具包及其依赖项。 - AlexT
visualizationToolkit 可在 "clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit" 找到。 - Yoav

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接