This is a migrated thread and some comments may be shown as answers.

SeriesDefinition Visibility Binding issue

4 Answers 109 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Dr.YSG
Top achievements
Rank 2
Dr.YSG asked on 20 Jan 2010, 09:11 PM
BubbleSeriesDefinition supports a property called "Visibility".

I can set it in XAML to a hard coded value:

                        <chart:BubbleSeriesDefinition BubbleSizeRelative="False" 
                                                      Visibility="Visible" 
                                                      ItemStyle="{StaticResource RadEventBubble}"></chart:BubbleSeriesDefinition> 
                    </chart:SeriesMapping.SeriesDefinition> 

But when I try setting it to a databound value, Silverlight has a fatal error and the application does not load (it is gettting a XAML parse error on the line with the binding to the Converter:

 
                                                      Visibility="{Binding EventDisplay, Converter={StaticResource Bool2Visible}, Mode=OneWay}" 
                                                      ItemStyle="{StaticResource RadEventBubble}"></chart:BubbleSeriesDefinition> 
                    </chart:SeriesMapping.SeriesDefinition> 

The probably is NOT in the converter, since I use that same converter in othe examples, and it returns the value Visibility.Collapsed or Visibility.Visible depending on the boolean value.

I am enclosing the converter, and you can see that it is providing the correct type (SeriesVisibility):
using System; 
using System.Windows; 
using System.Windows.Data; 
using Telerik.Windows.Controls.Charting; 
 
namespace BloodHound2 
    /// <summary> 
    /// converts a boolean to a XAML Visibility enum 
    /// </summary> 
    public class Bool2SeriesVisible : IValueConverter 
    { 
        #region public methods 
        /// <summary> 
        /// Conversion from bool to SeriesVisibility 
        /// </summary> 
        /// <param name="value"></param> 
        /// <param name="targetType"></param> 
        /// <param name="parameter"></param> 
        /// <param name="culture"></param> 
        /// <returns></returns> 
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 
        { 
            if (value != null && (bool)value) 
            { 
                return SeriesVisibility.Visible; 
            } 
            else 
            { 
                return SeriesVisibility.Collapsed; 
            } 
        } 
 
        /// <summary> 
        /// Conversion from Visibilty to bool is not possible. 
        /// </summary> 
        /// <param name="value"></param> 
        /// <param name="targetType"></param> 
        /// <param name="parameter"></param> 
        /// <param name="culture"></param> 
        /// <returns></returns> 
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 
        { 
            throw new NotImplementedException(); 
        } 
        #endregion 
    } 




4 Answers, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 22 Jan 2010, 01:48 PM
Hi Dr.YSG,

The SeriesDefinition.Visibility property is not a dependency property so you cannot use a binding expression to assign its value. Note that this cannot be improved at the moment as in Silverlight the binding target can be a DependencyProperty of a FrameworkElement only (not a generic DependencyObject) and the SeriesDefinition is a generic DependencyObject.


Regards,
Manuel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Dr.YSG
Top achievements
Rank 2
answered on 22 Jan 2010, 02:08 PM
Thank you.

BTW, I am using SilverLight 4 where any descendent of DependencyObject can be used for a DependencyProperty. Do you have plans to support this in your future releases (I am using your SL4 beta release, but obviously it is not yet supported there).

It is nice to be able to turn on and off layers (i.e. turn on and off a series) especially when the chart gets busy and one needs to visually contrast information from one series to another.


0
Accepted
Giuseppe
Telerik team
answered on 27 Jan 2010, 11:13 AM
Hello Dr.YSG,

Indeed you are right - the advent of Silverlight 4 will loosen the restrictions currently imposed on binding targets and we will certainly look into supporting this in one of the future versions of the control.



Kind regards,
Manuel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Jay Sanderson
Top achievements
Rank 1
answered on 26 Jul 2011, 12:30 PM
edit
Tags
Chart
Asked by
Dr.YSG
Top achievements
Rank 2
Answers by
Giuseppe
Telerik team
Dr.YSG
Top achievements
Rank 2
Jay Sanderson
Top achievements
Rank 1
Share this question
or