We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

convert ValueChanged event in LinearContentPointer to a command

i am using the CommunityToolkit in my maui app.

I would like to know how to convert the ValueChanged event in LinearContentPointer to a command.

I am able to convert the event LabelCreated in the SfLinearGauge by using EventToCommandBehavior. See code below:

                        <gauge:SfLinearGauge x:Name="heightCalculatorGauge"

                                 Minimum="0"

                                 Maximum="250"

                                 Interval="50" MinimumHeightRequest="120"

                                 HorizontalOptions="Center"

                                 MinorTicksPerInterval="0"

                                 Orientation="Vertical"

                                 TickPosition="Outside"

                                 LabelPosition="Outside">

                            <gauge:SfLinearGauge.Behaviors>//here it works

                                <toolkit:EventToCommandBehavior

                                    EventName="LabelCreated"

                                    Command="{Binding HeightLabelCreatedCommand}"

                                    EventArgsConverter="{StaticResource LabelCreatedEventArgsConverter}"/>

                            </gauge:SfLinearGauge.Behaviors>


                            <gauge:SfLinearGauge.MarkerPointers>

                                <gauge:LinearShapePointer Value="120"

                                              x:Name="heightCalculatorShape"

                                              ShapeType="Rectangle"

                                              Position="Outside"

                                              EnableAnimation="True"

                                              IsInteractive="True"

                                              ShapeHeight="1.5"

                                              ShapeWidth="165"

                                              Fill="#ff0074E3" >

                                    <gauge:LinearContentPointer.Behaviors>//ERROR: the attachable property "Behaviors" was not fount in type "LinearContentPointer"

                                        <toolkit:EventToCommandBehavior

                                    EventName="ValueChanged"

                                    Command="{Binding ValueChangedCommand}"

                                    EventArgsConverter="{StaticResource ValueChangedEventArgsConverter}"/>

                                    </gauge:LinearContentPointer.Behaviors>

                                </gauge:LinearShapePointer>

...MORE XAML....


but LinearContentPointer does not contains a list of Behavior. 


best regards.


3 Replies

VO Vishal Omprasad Syncfusion Team January 30, 2023 01:11 PM UTC

We regret to inform you that the behavior can only be included for VisualElement type, and unfortunately, the LinearContentPointer is not a VisualElement type. As a result, the command support for the ValueChanged event cannot be added to the LinearContentPointer.

 

We apologize for any disappointment this may cause and if there is anything else we can assist you with, please don't hesitate to reach out to us.




HS hassan salman January 31, 2023 01:21 AM UTC

Thank you for your response.


is there a way to convert this event to a command without behavior?



ET Eswaran Thirugnanasambandam Syncfusion Team January 31, 2023 02:02 PM UTC

We can invoke the command from the ValueChanged event as explained in the below link


https://dotnetdevaddict.co.za/2017/07/13/turning-events-into-commands/


We have prepared a sample to achieve your requirement and please get it from below attachment.


Attachment: LinearGaugeGettingStarted_d4ae9a7f.zip

Loader.
Live Chat Icon For mobile
Up arrow icon