【问题标题】:Silverlight DataVisualization Pie ChartsSilverlight 数据可视化饼图
【发布时间】:2014-03-11 10:56:42
【问题描述】:

我正在开发 Windows Phone 8 应用程序。

我正在使用 Silverlight DataVisualization 饼图。

有什么办法,当用户点击饼图切片时,可以获取该切片的值?还有双击?

这是我的代码:

<charting:Chart
                Style="{StaticResource PhoneChartStyle}"
                Template="{StaticResource PhoneChartPortraitTemplate}"
                x:Name="MyPieSeriesChart">
                <!-- Series -->
                <charting:PieSeries
                    ItemsSource="{StaticResource Activities}"
                    DependentValuePath="Count"
                    IndependentValuePath="Activity">
                    <charting:PieSeries.LegendItemStyle>
                        <Style TargetType="charting:LegendItem">
                            <Setter Property="Margin" Value="5 0 15 0"/>
                            <Setter Property="Foreground" Value="White"/>
                        </Style>
                    </charting:PieSeries.LegendItemStyle>
                </charting:PieSeries>
            </charting:Chart>

【问题讨论】:

    标签: c# wpf silverlight charts windows-phone


    【解决方案1】:

    要在pieseries中启用项目选择,您需要设置

    IsSelectionEnabled="True".
    

    获取切片值

     private void PieSeries_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            PieSeries p = sender as PieSeries;
            var a = p.SelectedItem;
        }
    

    【讨论】:

    • 好的,我已经设置好了,但是如何在点击该切片时获取值?
    • 我已经修改了答案
    • 谢谢它的工作,有什么办法可以在我点击切片时禁用颜色,或者假设我点击时是否有红色切片也应该是红色的跨度>
    • 如果对您有帮助,您能否将其标记为答案,您可以使用 blend 修改切片样式。
    • 是的,我会接受答案,你能告诉我如何修改切片样式吗,只需步骤也足够了
    猜你喜欢
    • 2021-08-01
    • 2019-10-19
    • 2019-01-06
    • 1970-01-01
    • 1970-01-01
    • 2010-10-08
    • 1970-01-01
    • 1970-01-01
    • 2013-11-03
    相关资源
    最近更新 更多