SeriesDefinition Visibility Binding issue

5 posts, 1 answers
  1. Dr.YSG
    Dr.YSG avatar
    193 posts
    Member since:
    Dec 2009

    Posted 20 Jan 2010 Link to this post

    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 
        } 




  2. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts
    Member since:
    Sep 2012

    Posted 22 Jan 2010 Link to this post

    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.

  3. Dr.YSG
    Dr.YSG avatar
    193 posts
    Member since:
    Dec 2009

    Posted 22 Jan 2010 Link to this post

    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.


  4. Answer
    Giuseppe
    Admin
    Giuseppe avatar
    2363 posts
    Member since:
    Sep 2012

    Posted 27 Jan 2010 Link to this post

    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.

  5. Jay Sanderson
    Jay Sanderson avatar
    9 posts
    Member since:
    May 2010

    Posted 26 Jul 2011 Link to this post

    edit

Back to Top