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
290
Binding on AxisLabelSettings.Visibility not wirking for CategoryDateTimeXAxis
posted

Hello,

For CategoryXAxis everything works OK:

<ig:CategoryXAxis x:Name="XAxis" ItemsSource="{Binding Data}" DateTimeMemberPath="X" Label="{}{X}">
    <ig:CategoryXAxis.LabelSettings>
        <ig:AxisLabelSettings>
            <ig:AxisLabelSettings.Visibility>
                <Binding Path="IsAxis1Visible" Mode="OneWay">
                    <Binding.Converter>
                        <common:AxisVisibilityConverter/>
                    </Binding.Converter>
                </Binding>
            </ig:AxisLabelSettings.Visibility>
        </ig:AxisLabelSettings>
    </ig:CategoryXAxis.LabelSettings>
</ig:CategoryXAxis>

but not for:

<ig:CategoryDateTimeXAxis x:Name="XAxis" ItemsSource="{Binding Data}" DateTimeMemberPath="X" Label="{}{X}">
    <ig:CategoryDateTimeXAxis.LabelSettings>
        <ig:AxisLabelSettings>
            <ig:AxisLabelSettings.Visibility>
                <Binding Path="IsAxis1Visible" Mode="OneWay">
                    <Binding.Converter>
                        <common:AxisVisibilityConverter/>
                    </Binding.Converter>
                </Binding>
            </ig:AxisLabelSettings.Visibility>
        </ig:AxisLabelSettings>
    </ig:CategoryDateTimeXAxis.LabelSettings>
</ig:CategoryDateTimeXAxis>

When I set it explicitly it works too:

<ig:CategoryDateTimeXAxis x:Name="XAxis" ItemsSource="{Binding Data}" DateTimeMemberPath="X" Label="{}{X}">
    <ig:CategoryDateTimeXAxis.LabelSettings>
        <ig:AxisLabelSettings>
            <ig:AxisLabelSettings.Visibility>
                <Visibility>Collapsed</Visibility>
            </ig:AxisLabelSettings.Visibility>
        </ig:AxisLabelSettings>
    </ig:CategoryDateTimeXAxis.LabelSettings>
</ig:CategoryDateTimeXAxis>

Converter:

    [ValueConversion(typeof(bool), typeof(Visibility))]
    public class AxisVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            try
            {
                var active = (bool)value;
                if (active)
                    return Visibility.Visible;
                return Visibility.Collapsed;
            }
            catch
            {
                return Visibility.Collapsed;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            try
            {
                var visibility = (Visibility)value;
                switch (visibility)
                {
                    case Visibility.Visible:
                        return true;
                    default:
                        return false;
                }
            }
            catch
            {
                return false;
            }
        }
    }

Parents Reply Children
No Data