我正在开发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>
答案 0 :(得分:1)
要在派对中启用项目选择,您需要设置
IsSelectionEnabled="True".
获取切片值
private void PieSeries_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
PieSeries p = sender as PieSeries;
var a = p.SelectedItem;
}