I have some Window(s) in my application that are meant to be encapsulated in a <ContentPresenter>
in its style. In this style, I build a template where I have some custom userControls like a custom titleBar and somewhere, the ContentPresenter
containing the content of any of the window(s). The goal is to extract the required xaml of each of the Window and put in a template in the style. Which is exactly what wpf is meant to be used for.
Then I wanted to have an event raised from all of those window(s) when the user clicks on its content anywhere. So I added in the style:
<ContentPresenter PreviewMouseDown="somethingMouseDowned" />
Note that, at first, I applied this to the grisd inside the window(s) and, in code behind (xaml.cs), I handled the event, doing what I wanted and everything was fine.
But I want the event handling to be invisible from the window(s). That is why I went with putting the PreviewMouseDown in the style. I also don't want any handling code in my code behind.
The problem is that I don't know how to handle the event somewhere else than in the code behind. I need alternatives.
Thanks in advance