This question is locked. New answers and comments are not allowed.
I have a LongListSelector where i want each item in the list to display a small pie. I am having trouble figuring out the data binding for the individual PieDataPoints. I have the ItemsSource set at the <phone:LongListSelector> level - do i also need to set the telerikChart:PieSeries level for the data binding? All I want to do is pluck two values out of the object bound to the LongListSelector.
<phone:LongListSelector Margin="0,0,-22,0" ItemsSource="{Binding Items}">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<Grid Margin="0,0,0,24">
<TextBlock FontSize="70" FontWeight="SemiBold" Foreground="#888888" HorizontalAlignment="Left" Margin="102,2,0,0" TextWrapping="Wrap" Text="{Binding HoursRemaining}" VerticalAlignment="Top"/>
<telerikChart:RadPieChart HorizontalAlignment="Left" Margin="0,10,0,0" VerticalAlignment="Top" Height="100" Width="66">
<telerikChart:PieSeries LabelFormat="''" BorderThickness="3">
<telerikChart:PieSeries.SliceStyles>
<Style TargetType="Path">
<Setter Property="Fill" Value="#E5DFD1"/>
</Style>
<Style TargetType="Path">
<Setter Property="Fill" Value="#96D341"/>
</Style>
</telerikChart:PieSeries.SliceStyles>
<Charting:PieDataPoint Value="{Binding TimeElapsed}"/>
<Charting:PieDataPoint Value="{Binding TimeRemaining}"/>
</telerikChart:PieSeries>
</telerikChart:RadPieChart>
<TextBlock Foreground="#008FF5" FontFamily="Segoe WP" FontSize="34" HorizontalAlignment="Left" Margin="180,11,-77,0" TextWrapping="Wrap" Text="{Binding Question}" VerticalAlignment="Top" Width="377"/>
<TextBlock Foreground="#00588C" FontWeight="SemiBold" FontSize="26" HorizontalAlignment="Left" Margin="118,72,0,0" TextWrapping="Wrap" Text="hrs" VerticalAlignment="Top"/>
<TextBlock Foreground="#888888" HorizontalAlignment="Left" Margin="180,96,0,0" TextWrapping="Wrap" Text="{Binding Text}" VerticalAlignment="Top"/>
</Grid>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
When I run this code, I am getting an unhandled exception.
{System.ArgumentException: Object of type 'System.Windows.Data.Binding' cannot be converted to type 'System.Nullable`1[System.Double]'.
at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
at MS.Internal.XamlMemberInfo.SetValue(Object target, Object value)
at MS.Internal.XamlManagedRuntimeRPInvokes.SetValue(XamlTypeToken inType, XamlQualifiedObject& inObj, XamlPropertyToken inProperty, XamlQualifiedObject& inValue)}
When I remove the two binding statements from the Charting:PieDataPoint elements (and just set them to static text) the exception goes away.
<phone:LongListSelector Margin="0,0,-22,0" ItemsSource="{Binding Items}">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<Grid Margin="0,0,0,24">
<TextBlock FontSize="70" FontWeight="SemiBold" Foreground="#888888" HorizontalAlignment="Left" Margin="102,2,0,0" TextWrapping="Wrap" Text="{Binding HoursRemaining}" VerticalAlignment="Top"/>
<telerikChart:RadPieChart HorizontalAlignment="Left" Margin="0,10,0,0" VerticalAlignment="Top" Height="100" Width="66">
<telerikChart:PieSeries LabelFormat="''" BorderThickness="3">
<telerikChart:PieSeries.SliceStyles>
<Style TargetType="Path">
<Setter Property="Fill" Value="#E5DFD1"/>
</Style>
<Style TargetType="Path">
<Setter Property="Fill" Value="#96D341"/>
</Style>
</telerikChart:PieSeries.SliceStyles>
<Charting:PieDataPoint Value="{Binding TimeElapsed}"/>
<Charting:PieDataPoint Value="{Binding TimeRemaining}"/>
</telerikChart:PieSeries>
</telerikChart:RadPieChart>
<TextBlock Foreground="#008FF5" FontFamily="Segoe WP" FontSize="34" HorizontalAlignment="Left" Margin="180,11,-77,0" TextWrapping="Wrap" Text="{Binding Question}" VerticalAlignment="Top" Width="377"/>
<TextBlock Foreground="#00588C" FontWeight="SemiBold" FontSize="26" HorizontalAlignment="Left" Margin="118,72,0,0" TextWrapping="Wrap" Text="hrs" VerticalAlignment="Top"/>
<TextBlock Foreground="#888888" HorizontalAlignment="Left" Margin="180,96,0,0" TextWrapping="Wrap" Text="{Binding Text}" VerticalAlignment="Top"/>
</Grid>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
When I run this code, I am getting an unhandled exception.
{System.ArgumentException: Object of type 'System.Windows.Data.Binding' cannot be converted to type 'System.Nullable`1[System.Double]'.
at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
at MS.Internal.XamlMemberInfo.SetValue(Object target, Object value)
at MS.Internal.XamlManagedRuntimeRPInvokes.SetValue(XamlTypeToken inType, XamlQualifiedObject& inObj, XamlPropertyToken inProperty, XamlQualifiedObject& inValue)}
When I remove the two binding statements from the Charting:PieDataPoint elements (and just set them to static text) the exception goes away.