Raising routed event from ViewModel in MVVM
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.
Re: Raising routed event from ViewModel in MVVM
Currently, this functionality is not supported. Interaction Triggers only support events that belong to the same class and do not support attached events. Could you please create a ticket regarding this issue?
As a workaround, you can expose new events in your main UserControl (Y) and implement them by registering to the events of the main UserControl (X) in the code
As a workaround, you can expose new events in your main UserControl (Y) and implement them by registering to the events of the main UserControl (X) in the code
Who is online
Users browsing this forum: Ahrefs [Bot] and 15 guests