Hello. I'm using Ultimate edition complect of your UI elements. I'm trying create a chart that have 2 possible state. First state have one Y axis and one ScatterLineSerie. Second state have two axis and two ScatterLineSerie (this state shown on the picture). All states a build on the same axis(Time). Values of Max, Min, Color and Visibility of axis are binded to the properties in VM. Axis of first state and one of the axis of second state positinated at the left.
Problem that after binding (and not only binding, even if manual set) axis that must be Collapsed are not collapsed (shown on the picture with red rectangle). At the same time Axis stroke are not visible.
Kind regards,
Alexey
public class AxisSettings : ObservableModel { public AxisSettings() { this.Visibility = Visibility.Visible; } private Visibility _visibility; public Visibility Visibility { get { return _visibility; } set { if (_visibility == value) return; _visibility = value; OnPropertyChanged("Visibility"); } } }
public abstract class ObservableModel : INotifyPropertyChanged { #region INotifyPropertyChanged public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string propertyName) { PropertyChangedEventHandler handler = this.PropertyChanged; if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName)); } public void OnAsyncPropertyChanged(string propertyName) { if (PropertyChanged != null) { Deployment.Current.Dispatcher.BeginInvoke(() => { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); }); } } #endregion }
I attached WPF application that performs the same task.
Hi mtrela.
First of all thanks for quick reply and for good example.
But... I don't sure it was misunderstooded mistake or something going wrong on my PC.
Cauz I have an a result of switching that the all three axis are shown on screen.
Anyway. I continue to digging around my problem. If you have any suggests why this can happens, it will be good.
P.S. I check this problem on 2 PC's. With same installed options. Check on version 10.3.20103.2196, 10.3.20103.2018 and 10.3.20103.1003/
I have found out from our Engineering team that the AxisLabelSettings is not part of the logical tree in the current version of xamDataChart control. As result it does not inherit the DataContext that I set in my sample solution and this is why all three axes were shown on screen. However, there is a work around that you can use to change the visibility of axis labels based on the state of data.
The work around for the issue of binding to properties of AxisLabelSettings is as follows:
1 Defined the data view model as a resource
<Window.Resources> <models:DataViewModel x:Key="dataVM" /> </Window.Resources>
2 Bind the data view model to the AxisLabelSettings by specifying source to a static resource
<ig:NumericYAxis.LabelSettings> <ig:AxisLabelSettings Extent="60" Visibility="{Binding Source={StaticResource dataVM}, Path=DataStates[0].LeftAxisSettings.Visibility}" Location="OutsideLeft" /> </ig:NumericYAxis.LabelSettings>
I attached revised version of my sample project with the work around so you can try it on your own. Let me know if you have more questions about this or if something is not clear.
Is there now (Version 12.1) a more direct possibility to bind the axis-Visibility to e.g. a Checkbox?In my case, using a booleanToVisibility converter, the lineseries is already hiding but the axis of the series is still visible and doesn't care about the Visibility-Binding.
ah I understand, thank you for the feedback - so this is just bad luck for me.
Hello Joachim,
Since the AxisLabelSettings is not a visual element, it is not in the Visual Tree and it cannot be bind via the DataContext or ElementName. As you can see in the sample it can be bound only to a Source by Setting the Binding’s Source Property.
Ok, I added some code (ToggleCheckBox and BooleanToVisibilityConverter) to the example from above to show what's not working.
As you can see the line series is hiding but the axis is still visible - in both cases im binding to a property. So, whats the difference?
Regards Joachim
ok, so there is no other way than handle the visibility via the model?
I'm currently struggeling with, that I don't really understand what's the difference - in both cases the Visibility-Property of the axis and axis-label is binding to a property. In my case it's the IsChecked-Property of a checkbox (using a boolean-to-visibility-converter) in the above shown case its a specific property of the underlying model. But the version with the checkbox isn't working in my case.
Maybe you can help me understand?
thanks in advanced and kind regardsJoachim
Hello,
Thank you for your post. I have been looking into it and I can say that still the best way to control the Visibility of the Axis'Labels is the approach Martin suggested.