【问题标题】:PieChart in WinRT XAML ToolkitWinRT XAML 工具包中的饼图
【发布时间】:2015-07-20 10:04:08
【问题描述】:

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

我从 WinRT XAML Toolkit 添加了一个 饼图,其中包含 6 个项目。默认的饼图只有 3 种颜色。因此,我在其中添加了 6 ResourceDictionaries。此 PieChart 的索引是 6 种颜色,但 PieChart 仍然显示为 3 种颜色。

截图: Uploaded ScreenShot

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;

【问题讨论】:

    标签: xaml windows-runtime windows-phone windows-phone-8.1 winrt-xaml-toolkit


    【解决方案1】:

    重建项目。 从移动设备中删除测试应用。 重新安装应用。

    【讨论】:

    • 您的意思是说重建(+其他步骤)解决了问题吗?我已经看到 C++/XAML 项目在重新编译其 XAML 时遇到问题,而后面的代码没有任何变化,但您似乎正在使用 C#。您使用的是哪个 Visual Studio 版本?你是用 Nuget 来抓取工具包的吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-20
    • 1970-01-01
    相关资源
    最近更新 更多