To achieve this, you can use the command. Ask Button in the DataTemplate to execute specific Command s:
<Button Command="{x:Static MyCommands.SomeCommand}"/>
Then each view that uses the DataTemplate processes Command :
<UserControl> <UserCommand.CommandBindings> <CommandBinding Command="{x:Static MyCommands.SomeCommand}" Executed="_someHandler"/> </UserCommand.CommandBindings> </UserControl>
EDIT after comments: After you have created the code for your ResourceDictionary according to these instructions , you can simply connect events in the usual way:
In MyResources.xaml :
<ListBox x:Key="myListBoxResource" ItemSelected="_listBox_ItemSelected"/>
Then in MyResources.xaml.cs :
private void _listBox_ItemSelected(object sender, EventArgs e) { ... }
source share