When you hit the OK button in the application window, it triggers the event associated with the button click. In our case, it's the OnOkClicked event, inside the ColorMixer class. It then routes the event to the custom event OkButtonClick, which gets caught in the originating place. It's the OnOkClicked event listener in our MainWindow.xaml.
Similarly, when you click on the Cancel button, it raises the Click event inside the ColorMixer class and then routes to the MainWindow. If the association is present, it gets called. In our case, it's the OnCancelClicked handler in MainWindow which triggers the message box.