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.
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.
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
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
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.
ah I understand, thank you for the feedback - so this is just bad luck for me.