4 Answers, 1 is accepted
0
Hi Geoffrey,
Yavor
the Telerik team
We have made DateTimeContinusousAxis.Maximum property a dependency property for the Q1 release. Before that it was a regular property and binding it will throw an exception, since bindings are only supported on dependency property.
All the best,Yavor
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
MikeWiese
Top achievements
Rank 1
answered on 26 Jun 2012, 07:54 AM
So how would you write code to programatically bind a viewmodel property to an axis min or max?
0
Hello Mike,
Here is a sample code snippet to get you started:
XAML
C#
Hope this helps.
Greetings,
Giuseppe
the Telerik team
Here is a sample code snippet to get you started:
XAML
<telerik:RadCartesianChart x:Name="RadChart1" />C#
using System;using System.Collections.Generic;using System.Windows.Controls;using System.Windows.Data;using Telerik.Windows.Controls;using Telerik.Windows.Controls.ChartView;namespace SilverlightApplication15{ public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); this.DataContext = new ViewModel(); DateTimeContinuousAxis horizontalAxis = new DateTimeContinuousAxis() { LabelFormat = "dd/MM/yyyy" }; horizontalAxis.SetBinding(DateTimeContinuousAxis.MinimumProperty, new Binding("AxisMinimum")); RadChart1.HorizontalAxis = horizontalAxis; RadChart1.VerticalAxis = new LinearAxis(); BarSeries series = new BarSeries(); series.CategoryBinding = new PropertyNameDataPointBinding("Date"); series.ValueBinding = new PropertyNameDataPointBinding("Value"); series.ItemsSource = (this.DataContext as ViewModel).Data; RadChart1.Series.Add(series); } } public class ViewModel : ViewModelBase { private Random rand = new Random(123456); private List<ChartData> _data; private DateTime _axisMinimum; public ViewModel() { this.Data = this.GetData(); this.AxisMinimum = DateTime.Today.AddDays(-10); } public List<ChartData> Data { get { return this._data; } set { if (this._data != value) { this._data = value; this.OnPropertyChanged("Data"); } } } public DateTime AxisMinimum { get { return this._axisMinimum; } set { if (this._axisMinimum != value) { this._axisMinimum = value; this.OnPropertyChanged("AxisMinimum"); } } } private List<ChartData> GetData() { List<ChartData> data = new List<ChartData>(); for (int i = 0; i < 10; i++) { data.Add(new ChartData() { Date = DateTime.Today.AddDays(i), Value = rand.Next(10, 100) }); } return data; } } public class ChartData { public DateTime Date { get; set; } public double Value { get; set; } }}Hope this helps.
Greetings,
Giuseppe
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
MikeWiese
Top achievements
Rank 1
answered on 29 Jun 2012, 11:22 AM
Thank you Giuseppe