I have a PlayerV.xaml View with a Slider inside:
<Slider Value="{Binding CurrentProgress}"/>
and have a button:
<Button Content="next song" Command="{Binding playNext}"/>
Button works correct. Button's playNext command is contained in PlayerVM.cs
I want slider's ValueChanged to call a function which is stored in PlayerVM.cs:
[1]:<Slider Value="{Binding CurrentProgress}" ValueChanged="{Binding playNext}"/>
I know [1] has an incorrect syntax, I used it for sake of clarity of explanation.
====Additional Explanation====
I know I can write:
<Slider ValueChanged="Slider_ValueChanged" Value="{Binding CurrentProgress}" />
And in PlayerV.xaml.cs there will be
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
//some logic (actions)
}
}
But I don't want any logic in there. I want it to be in PlayerVM.cs (like button's command handler functions). How to do that? Also in my App.xaml.cs startup function is:
private void OnStartup(object sender, StartupEventArgs e)
{
MainWindow _mainWindow = new MainWindow();
PlayerVM playerVM = new PlayerVM();
_mainWindow.DataContext = playerVM;
_mainWindow.Show();
}