RadCartesianChart图表控件对象名称的获取方法

本文介绍了一个Silverlight应用中实现的图表视图系列类型动态切换功能,包括依赖属性注册、获取和设置系列类型,以及根据系列类型清空并重新添加图表系列的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://demos.telerik.com/silverlight/#ChartView/Gallery/Linear

待研究


 public static readonly DependencyProperty SeriesTypeProperty = DependencyProperty.RegisterAttached("SeriesType",
            typeof(string), typeof(ChartSeriesTypeSwitch), new PropertyMetadata(OnSeriesTypeChanged));


        public static string GetSeriesType(DependencyObject obj)
        {
            return (string)obj.GetValue(SeriesTypeProperty);
        }


        public static void SetSeriesType(DependencyObject obj, string value)
        {
            obj.SetValue(SeriesTypeProperty, value);
        }


        private static void OnSeriesTypeChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            RadCartesianChart chart = sender as RadCartesianChart;
            if (chart == null)
                return;
            
            string seriesType = e.NewValue as string;
            chart.Series.Clear();
            foreach (CartesianSeries series in GetSeries(chart, seriesType))
            {
                chart.Series.Add(series);
            }


            CategoricalAxis categoricalAxis = chart.HorizontalAxis as CategoricalAxis;
            if (categoricalAxis != null)
            {
                AxisPlotMode plotMode = AxisPlotMode.BetweenTicks;
                if (seriesType == "Area" || seriesType == "Spline Area")
                {
                    plotMode = AxisPlotMode.OnTicks;
                }
                categoricalAxis.PlotMode = plotMode;
            }
        }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值