tl;dr: Changed Windows to two Pages and a NavigationWindow, ICommand Bindings stopped working.
So I copied the Grid from my MainWindow to a fresh MainPage, setup the NavigationWindow and so on. All is set, build without error, even the Binding for Strings and others are working. What does not work, are the ICommand Bindings for my Buttons. But they did work before.
Example ICommand:
class ComPortChosen : ICommand
{
private MainViewModel mainVm;
public ComPortChosen(MainViewModel mainVm)
{
this.mainVm = mainVm;
}
bool ICommand.CanExecute(object parameter)
{
return true;
}
event EventHandler ICommand.CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
void ICommand.Execute(object parameter)
{
//set a breakpoint here, method was **not** entered
int i = 1337;
}
}
In the MainViewModel.class:
public ICommand chooseComPort { get; set; }
private MainPage mainPage;
public MainViewModel(MainView view)
{
chooseComPort = new ComPortChosen(this);
mainPage = new MainPage(this);
}
In my MainPage.xaml:
<Button
x:Name="btn_choose"
Content="Choose" Grid.Column="10" Grid.Row="2"
Command="{Binding chooseComPort}" Margin="0,49,0,0"/>
Since the other Bindings (strings, bool, custom converter) do work, I assume that I set up the DataContext correctly.