SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

0
0

Whenever possible I like to do simple UI related things such as changing the MouseWheelZoomModifier direction from Xaml.

My first attempt at this was to use DataTriggers on the MouseWheelZoomModifier bound to check boxes as such.

That did not work so I switched it to this. Radio buttons for mutually exclusive selection…

<StackPanel Orientation="Horizontal">
<RadioButton x:Name="xDirection"
Margin="5,3"
IsChecked="{Binding ElementName=mouseWheelZoomModifierX, Path=IsEnabled}"
Content="Zoom X Only" />

            &lt;RadioButton x:Name=&quot;yDirection&quot;
                      Margin=&quot;5,3&quot;
                      IsChecked=&quot;{Binding ElementName=mouseWheelZoomModifierY, Path=IsEnabled}&quot;
                      Content=&quot;Zoom Y Only&quot; /&gt;

            &lt;RadioButton x:Name=&quot;xyDirection&quot;
                      Margin=&quot;5,3&quot;
                      IsChecked=&quot;{Binding ElementName=mouseWheelZoomModifierXY, Path=IsEnabled}&quot;
                      Content=&quot;Zoom X&amp;amp;Y&quot; /&gt;

And three separate zoom modifiers…

<SciChart:MouseWheelZoomModifier x:Name="mouseWheelZoomModifierX"
IsEnabled="False"
XyDirection="XDirection" />
<SciChart:MouseWheelZoomModifier x:Name="mouseWheelZoomModifierY"
IsEnabled="False"
XyDirection="YDirection" />
<SciChart:MouseWheelZoomModifier x:Name="mouseWheelZoomModifierXY"
IsEnabled="True"
XyDirection="XYDirection" />

Am I missing something with the Triggers? If not this is working fine, it just seems like an odd way to do it…

  • You must to post comments
0
0

Hi Dwaldo,

You could do this in many ways. I think better approach to do this could be using ComboBox with XyDirection members and bind MouseWheelZoomModifier to its SelectedItem, or ToggleButton for it has three states, so you can write Converter and bind MouseWheelZoomModifier to IsChecked property, or you could modify your code in a such way:

            <CheckBox x:Name="xDirection"
                      Margin="5,3"
                      Checked="XDirection_Checked"
                      IsChecked="{Binding XyDirection, ElementName=mouseWheelZoomModifier, Mode=OneWayToSource, Converter={StaticResource directionConverter}, ConverterParameter=XDirection}"
                      Content="X Direction Only" />
            <CheckBox x:Name="yDirection"
                      Margin="5,3"
                      Checked="YDirection_Checked"
                      IsChecked="{Binding XyDirection, ElementName=mouseWheelZoomModifier, Mode=OneWayToSource, Converter={StaticResource directionConverter}, ConverterParameter=YDirection}"
                      Content="Y Direction Only" />
            <CheckBox x:Name="xyDirection"
                      Margin="5,3"
                      Checked="XYDirection_Checked"
                      IsChecked="{Binding XyDirection, ElementName=mouseWheelZoomModifier, Mode=OneWayToSource, Converter={StaticResource directionConverter}, ConverterParameter=XYDirection}"
                      Content="Both X and Y Direction" />

And one zoom modifier:

            <sciChart:SciChartSurface.ChartModifier>
                <sciChart:ModifierGroup>
                    <sciChart:MouseWheelZoomModifier x:Name="mouseWheelZoomModifier" />
                </sciChart:ModifierGroup>
            </sciChart:SciChartSurface.ChartModifier>

And the converter code:

    class DirectionConverter: IValueConverter
    {
        private XyDirection _selectedDirection;

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return Enum.Parse(typeof(XyDirection), (string)parameter);
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if((bool)value)
            {
                _selectedDirection = (XyDirection)Enum.Parse(typeof(XyDirection), (string)parameter);
            }

            return _selectedDirection;
        }
    }

You should use only one MouseWheelZoomModifier in any case. So if you will have more questions, we will be glad to help!

Best regards,
Yuriy

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.