Answer the question
In order to leave comments, you need to log in
How to correctly handle an event in WPF?
We need to handle the KeyDown event on a Slider in WPF. As far as I understand, the use of events is discouraged in MVVM. How to implement our plans with the help of commands and what would be the best solution?
Answer the question
In order to leave comments, you need to log in
They are just used a little differently. If you are not yet using a framework for MVVM, then I advise you to start right away with it. For example Prism:
add
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
<Button Content="нажать" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="KeyDown">
<i:InvokeCommandAction Command="{Binding KeyDownCommand}" CommandParameter="param"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question