Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
140
XamDataChart CategoryDateTimeAxis out of sync
posted

Below are 2 snippets of code for the VM that builds the chart, and the VM that applies the data to show the chart:

The Chart VM:

if (axisVm is CategoryDateTimeXAxisVM)

                {

                    CategoryDateTimeXAxisVM vm = (CategoryDateTimeXAxisVM) axisVm;

                    CategoryDateTimeXAxis categoryDateTimeAxis = new CategoryDateTimeXAxis();

                    categoryDateTimeAxis.Label = vm.Label;

                    categoryDateTimeAxis.DateTimeMemberPath = vm.DateTimeMemberPath;

                    categoryDateTimeAxis.MinimumValue = DateTime.Now.AddYears(-50);

                    categoryDateTimeAxis.MaximumValue = DateTime.Now;

 

                    //BindingOperations.SetBinding(categoryDateTimeAxis, CategoryDateTimeXAxisVM.MinimumDateTimeProperty,

                    //                                   new Binding("MinimumDateTime") { Source = vm, Mode = BindingMode.TwoWay });

 

                    //BindingOperations.SetBinding(categoryDateTimeAxis, CategoryDateTimeXAxisVM.MaximumDateTimeProperty,

                    //                                   new Binding("MaximumDateTime") { Source = vm, Mode = BindingMode.TwoWay });

 

                    axis = categoryDateTimeAxis;

 

                    BindingOperations.SetBinding(axis, CategoryAxisBase.ItemsSourceProperty,

                        new Binding("Rows") {Source = chartVm});

 

                    axis.LabelSettings = new AxisLabelSettings

                    {

                        Location = xAxis++ % 2 == 0

                            ? AxisLabelsLocation.OutsideBottom

                            : AxisLabelsLocation.OutsideTop,

                        Visibility = Visibility.Collapsed

                    };

 

                    if (xAxis == 1)

                        axis.LabelSettings.Visibility = Visibility.Visible;

                }

 

The VM tied to the View

if (earliest != null)

                    {

                        if (earliest.MonthDate != null)

                        {

                            DateTime dt = earliest.MonthDate.Value;

 

                            DatumTimeChart.X1.MinimumDateTime = dt;

                            //DatumTimeChart.X2.MinimumDateTime = dt;

                        }

                    }

 

The commented out bindging in the first code snipped causes all the axes lines to appear, and possibly be out of sync.  The way it shows (the uncommented sections) it works.  It should be noted that the second snipped is in an asyn method and has to be due to the amount of data.

 

Any suggestions on how to bind the value of the Min/Max axes values when called?