在WinRT XAML工具包中的PieChart



我正在写一个Windows Phone应用程序(WinRT 8.1)

我从WinRT XAML Toolkit中添加了一个Piechart,其中有6个项目。默认的PieChart只有3种颜色。因此,我在其中添加了6个ResourceDictionaries。这个PieChart的指数有6种颜色,但PieChart仍然显示为3种颜色。

截图:上传截图

XAML:

<Charting:Chart Name="Question">
    <Charting:Chart.Palette>
        <Charting:ResourceDictionaryCollection>
        <!-- Lemon Green -->
            <ResourceDictionary>
                <SolidColorBrush
                x:Key="Background"
                Color="#FFA5C127" />
                <Style
                x:Key="DataPointStyle"
                TargetType="Control">
                <Setter
                Property="Background"
                Value="{StaticResource Background}" />
                </Style>
                <Style
                x:Key="DataShapeStyle"
                TargetType="Shape">
                <Setter
                Property="Stroke"
                Value="{StaticResource Background}" />
                <Setter
                Property="StrokeThickness"
                Value="2" />
                <Setter
                Property="StrokeMiterLimit"
                Value="1" />
                <Setter
                Property="Fill"
                Value="{StaticResource Background}" />
                </Style>
            </ResourceDictionary>
            <!-- Blue -->
                <ResourceDictionary>
                <SolidColorBrush
                x:Key="Background"
                Color="#FF0E749B" />
                <Style
                x:Key="DataPointStyle"
                TargetType="Control">
                <Setter
                Property="Background"
                Value="{StaticResource Background}" />
                </Style>
                <Style
                x:Key="DataShapeStyle"
                TargetType="Shape">
                <Setter
                Property="Stroke"
                Value="{StaticResource Background}" />
                <Setter
                Property="StrokeThickness"
                Value="2" />
                <Setter
                Property="StrokeMiterLimit"
                Value="1" />
                <Setter
                Property="Fill"
                Value="{StaticResource Background}" />
                </Style>
            </ResourceDictionary>
        <!-- Red -->
            <ResourceDictionary>
                <SolidColorBrush
                x:Key="Background"
                Color="#FFA60606" />
                <Style
                x:Key="DataPointStyle"
                TargetType="Control">
                <Setter
                Property="Background"
                Value="{StaticResource Background}" />
                </Style>
                <Style
                x:Key="DataShapeStyle"
                TargetType="Shape">
                <Setter
                Property="Stroke"
                Value="{StaticResource Background}" />
                <Setter
                Property="StrokeThickness"
                Value="2" />
                <Setter
                Property="StrokeMiterLimit"
                Value="1" />
                <Setter
                Property="Fill"
                Value="{StaticResource Background}" />
                </Style>
            </ResourceDictionary>
        <!-- Green -->
            <ResourceDictionary>
                <SolidColorBrush
                x:Key="Background"
                Color="#FF54BD0B" />
                <Style
                x:Key="DataPointStyle"
                TargetType="Control">
                <Setter
                Property="Background"
                Value="{StaticResource Background}" />
                </Style>
                <Style
                x:Key="DataShapeStyle"
                TargetType="Shape">
                <Setter
                Property="Stroke"
                Value="{StaticResource Background}" />
                <Setter
                Property="StrokeThickness"
                Value="2" />
                <Setter
                Property="StrokeMiterLimit"
                Value="1" />
                <Setter
                Property="Fill"
                Value="{StaticResource Background}" />
                </Style>
            </ResourceDictionary>
        <!-- Sky Blue -->
            <ResourceDictionary>
                <SolidColorBrush
                x:Key="Background"
                Color="#FF08A4DE" />
                <Style
                x:Key="DataPointStyle"
                TargetType="Control">
                <Setter
                Property="Background"
                Value="{StaticResource Background}" />
                </Style>
                <Style
                x:Key="DataShapeStyle"
                TargetType="Shape">
                <Setter
                Property="Stroke"
                Value="{StaticResource Background}" />
                <Setter
                Property="StrokeThickness"
                Value="2" />
                <Setter
                Property="StrokeMiterLimit"
                Value="1" />
                <Setter
                Property="Fill"
                Value="{StaticResource Background}" />
                </Style>
            </ResourceDictionary>
        <!-- Dark Brown -->
            <ResourceDictionary>
                <SolidColorBrush
                x:Key="Background"
                Color="#FF3A0401" />
                <Style
                x:Key="DataPointStyle"
                TargetType="Control">
                <Setter
                Property="Background"
                Value="{StaticResource Background}" />
                </Style>
                <Style
                x:Key="DataShapeStyle"
                TargetType="Shape">
                <Setter
                Property="Stroke"
                Value="{StaticResource Background}" />
                <Setter
                Property="StrokeThickness"
                Value="2" />
                <Setter
                Property="StrokeMiterLimit"
                Value="1" />
                <Setter
                Property="Fill"
                Value="{StaticResource Background}" />
                </Style>
            </ResourceDictionary>
        </Charting:ResourceDictionaryCollection>
    </Charting:Chart.Palette>
    <Charting:PieSeries 
    IndependentValuePath="Item1"
    DependentValuePath="Item2" 
    IsSelectionEnabled="False"/>
</Charting:Chart>
c#

:

List<Tuple<string, int>> QuestionList = new List<Tuple<string, int>>()
{
    new Tuple<string, int>(Str1, v1),
    new Tuple<string, int>(Str2, v2)
};
Question.Title = "Pie Chart";
(Question.Series[0] as PieSeries).ItemsSource = QuestionList;

重建项目。从移动端删除测试应用。重新安装应用程序

最新更新