DragComplete event thru MVVM - maybe there is a much more efficient way

Hi,


I try to get the DragComplete Event thru MVVM from the SFRangeSlider. I came up with like the code below, but maybe there is a more better way to do this:

IN XAML:

  <range:SfRangeSlider

                                    Margin="0,0,0,0"

                                    DragCompleted="SfRangeSlider_DragCompleted"

                                    FontAttribute="None"

                                    FontSize="12"

                                    HeightRequest="60"

                                    KnobColor="LightSlateGray"

                                    LabelPlacement="TopLeft"

                                    Maximum="{Binding TotalDistance}"

                                    Minimum="0"

                                    Orientation="Horizontal"

                                    ShowCustomLabel="False"

                                    ShowRange="False"

                                    ShowValueLabel="False"

                                    StepFrequency="0.01"

                                    ThumbSize="1"

                                    TickColor="Black"

                                    TickPlacement="None"

                                    ToolTipPlacement="None"

                                    ToolTipPrecision="2"

                                    TrackColor="DarkGray"

                                    TrackSelectionColor="DeepSkyBlue"

                                    TrackSelectionThickness="1"

                                    TrackThickness="3"

                                    ValuePlacement="BottomRight"

                                    Value="{Binding DistanceEnergy, Mode=TwoWay}">

                                    <range:SfRangeSlider.CustomLabels>

                                                        <local:ObservableCollectionList>

                                                            <range:Items Label="{Binding AdditionalWeightSliderMin}" Value="{Binding AdditionalWeightSliderMin}" />

                                                            <range:Items Label="{Binding AdditionalWeightSliderMax}" Value="{Binding AdditionalWeightSliderMax}" />

                                                        </local:ObservableCollectionList>

                                                    </range:SfRangeSlider.CustomLabels>

                                        <range:SfRangeSlider.Behaviors>

                                            <behaviors:EventToCommandBehavior Command="{Binding DragCompletedCommand}" EventName="DragCompleted"/>

                                        </range:SfRangeSlider.Behaviors>

                                    </range:SfRangeSlider>

IN Viewmodel:

        public Command DragCompletedCommand

        {

            get;

            set;

        }

        public EvaluateViewModel()

        {

             DragCompletedCommand = new Command(DragComplete);

         }

        public void DragComplete()

        {

              // do something here

        }


3 Replies 1 reply marked as answer

SS Suganya Sethuraman Syncfusion Team August 9, 2021 09:15 AM UTC

Hi Markus,

Greetings from Syncfusion.

We have analyzed your requirement. We have prepared sample with DragCompleted event of SfRangeSlider using EventToCommand behavior.

Please have a sample for your reference,

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/RangeSliderXamarin-2008847964

Please check if the sample satisfies your requirement and let us know if you have any concerns.

Regards,
Suganya Sethuraman.
 
 



MA Markus August 9, 2021 11:19 AM UTC

Hi  Suganya,


thanks :) I have one more question, what is the advantage to do it the way you showed me over my solution. Both are working. The only advantage I can see, is t hat is will also have in the obj the Paramter true for thumb up delivered


Thanks a lot,

Markus



RS Ruba Shanmugam Syncfusion Team August 10, 2021 09:24 AM UTC

Hi Markus, 
 
Thanks for the update. EventToCommandBehavior can be used in both ways. The only advantage of using our sample is that you can obtain the DragThumbEventArgs value when the event is triggered. 
 
Please let us know, if you have any concerns. 
 
Regards, 
Ruba Shanmugam 


Marked as answer
Loader.
Up arrow icon