Permalink
Browse files

BUGFIX: using PieChart in a Pivot sometimes resulted in exception

  • Loading branch information...
1 parent f8b5201 commit b75e93b02bc4481068aa532b99f3992e81ed8b5a @ailon committed Feb 7, 2011
@@ -0,0 +1,53 @@
+<phone:PhoneApplicationPage
+ x:Class="QuickChartsWP7App.PivotPage1"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
+ xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
+ xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:amq="clr-namespace:AmCharts.Windows.QuickCharts;assembly=AmCharts.Windows.QuickCharts.WP"
+ mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
+ FontFamily="{StaticResource PhoneFontFamilyNormal}"
+ FontSize="{StaticResource PhoneFontSizeNormal}"
+ Foreground="{StaticResource PhoneForegroundBrush}"
+ SupportedOrientations="Portrait" Orientation="Portrait"
+ shell:SystemTray.IsVisible="True" Loaded="PhoneApplicationPage_Loaded">
+
+ <!--LayoutRoot is the root grid where all page content is placed-->
+ <Grid x:Name="LayoutRoot" Background="Transparent">
+ <!--Pivot Control-->
+ <controls:Pivot Title="MY APPLICATION">
+ <!--Pivot item one-->
+ <controls:PivotItem Header="item1">
+ <Grid>
+ <amq:PieChart x:Name="pie1"
+ TitleMemberPath="title"
+ ValueMemberPath="value"
+ >
+
+ </amq:PieChart>
+ </Grid>
+ </controls:PivotItem>
+
+ <!--Pivot item two-->
+ <controls:PivotItem Header="item2">
+ <Grid/>
+ </controls:PivotItem>
+ </controls:Pivot>
+ </Grid>
+
+ <!--Sample code showing usage of ApplicationBar-->
+ <!--<phone:PhoneApplicationPage.ApplicationBar>
+ <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
+ <shell:ApplicationBarIconButton x:Name="appbar_button1" IconUri="/Images/appbar_button1.png" Text="Button 1"/>
+ <shell:ApplicationBarIconButton x:Name="appbar_button2" IconUri="/Images/appbar_button2.png" Text="Button 2"/>
+ <shell:ApplicationBar.MenuItems>
+ <shell:ApplicationBarMenuItem x:Name="menuItem1" Text="MenuItem 1"/>
+ <shell:ApplicationBarMenuItem x:Name="menuItem2" Text="MenuItem 2"/>
+ </shell:ApplicationBar.MenuItems>
+ </shell:ApplicationBar>
+ </phone:PhoneApplicationPage.ApplicationBar>-->
+
+</phone:PhoneApplicationPage>
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Shapes;
+using Microsoft.Phone.Controls;
+using System.Collections.ObjectModel;
+using QuickChartsWPApp;
+
+namespace QuickChartsWP7App
+{
+ public partial class PivotPage1 : PhoneApplicationPage
+ {
+ public PivotPage1()
+ {
+ InitializeComponent();
+ }
+
+ public ObservableCollection<PData> Data = new ObservableCollection<PData>()
+ {
+ new PData() { title = "slice #1", value = 30 },
+ new PData() { title = "slice #2", value = 60 },
+ new PData() { title = "slice #3", value = 40 },
+ new PData() { title = "slice #4", value = 10 },
+ };
+
+ private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
+ {
+ pie1.DataSource = Data;
+ }
+ }
+}
@@ -17,7 +17,7 @@
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT"/>
</Capabilities>
<Tasks>
- <DefaultTask Name ="_default" NavigationPage="MainPage.xaml"/>
+ <DefaultTask Name ="_default" NavigationPage="PivotPage1.xaml"/>
</Tasks>
<Tokens>
<PrimaryToken TokenID="QuickChartsWP7AppToken" TaskName="_default">
@@ -49,6 +49,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Phone" />
+ <Reference Include="Microsoft.Phone.Controls, Version=7.0.0.0, Culture=neutral, PublicKeyToken=24eec0d8c86cda1e, processorArchitecture=MSIL" />
<Reference Include="Microsoft.Phone.Interop" />
<Reference Include="System.Windows" />
<Reference Include="system" />
@@ -66,6 +67,9 @@
<Compile Include="PieChart.xaml.cs">
<DependentUpon>PieChart.xaml</DependentUpon>
</Compile>
+ <Compile Include="PivotPage1.xaml.cs">
+ <DependentUpon>PivotPage1.xaml</DependentUpon>
+ </Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
@@ -96,6 +100,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
+ <Page Include="PivotPage1.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\QuickChartsWP\QuickChartsWP.csproj">
View
@@ -279,11 +279,13 @@ private void AddSlices()
}
#if WINDOWS_PHONE
+ private bool isSliceEvent = false;
void OnSliceManipulationStarted(object sender, ManipulationStartedEventArgs e)
{
GeneralTransform gt = (sender as Slice).TransformToVisual(_sliceCanvasDecorator);
DisplayBalloon(sender as Slice, gt.Transform(e.ManipulationOrigin));
- e.Handled = true;
+ //e.Handled = true;
+ isSliceEvent = true;
}
/// <summary>
@@ -292,8 +294,15 @@ void OnSliceManipulationStarted(object sender, ManipulationStartedEventArgs e)
/// <param name="e">Manipulation event arguments</param>
protected override void OnManipulationStarted(ManipulationStartedEventArgs e)
{
- HideBaloon();
- SwitchLegend();
+ if (!isSliceEvent)
+ {
+ HideBaloon();
+ SwitchLegend();
+ }
+ else
+ {
+ isSliceEvent = false;
+ }
}
private void SwitchLegend()

0 comments on commit b75e93b

Please sign in to comment.