Raising routed event from ViewModel in MVVM
Posted: 18 Jul 2024, 16:40
Hey, my question is as follows:
I've created a UserControl (lets call it X) that contains a noesis slider as part of it.
The NoesisSlider comes with a routed event named "ValueChanged" that is raised when the value changes.
Im using X UserControl in a different UserControl(Y) that functions as my main user control.
Both of them are implemented with MVVM pattern, so i have a view class and a view model class for both of them.
My question is, how can i catch this slider routed event in Y userControl?
The code above sits in the XAML of my main UserControl(Y).
This approach doesnt work, i cant seem to catch the event.
I also tried creating a routed event in my Y UserControl, but then i want it to be bound the the "ValueChanged" event from the slider, and i cant figure out a way to do so, since my only interaction with this event is from the command that sits in the viewmodel.
I've created a UserControl (lets call it X) that contains a noesis slider as part of it.
The NoesisSlider comes with a routed event named "ValueChanged" that is raised when the value changes.
Im using X UserControl in a different UserControl(Y) that functions as my main user control.
Both of them are implemented with MVVM pattern, so i have a view class and a view model class for both of them.
My question is, how can i catch this slider routed event in Y userControl?
Code: Select all
<!-- Right Slider -->
<Canvas Width="112.5" Height="662.5" Canvas.Top="0" Canvas.Left="180.5">
<customControls:cCustomSliderView Icon="2" x:Name="RightSlider" DataContext="{Binding RightSliderViewModel}"/>
<b:Interaction.Triggers>
<b:EventTrigger EventName="ValueChanged">
<b:InvokeCommandAction Command="{Binding SliderValueChangedCommand}"/>
</b:EventTrigger>
</b:Interaction.Triggers>
This approach doesnt work, i cant seem to catch the event.
I also tried creating a routed event in my Y UserControl, but then i want it to be bound the the "ValueChanged" event from the slider, and i cant figure out a way to do so, since my only interaction with this event is from the command that sits in the viewmodel.