I have a DataTemplate with a ListView control. This DataTemplate is located in Templates.xaml (which is a ResourceDictionary). Template.xaml is then included into my main UserControl SourceManager.xaml through ResourceDictionary.MergedDictionaries. I want to raise the SelectionChanged event of the DataTemplate's ListView but I want the handler in the code behind to be in SourceManager.xaml.cs.

How can I achieve that?

Templates.xaml:

  x:Class="LawBib.Templates"
         
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

x:Key="SectionTemplate">
   

       
Text="{Binding XPath=@Title}" />
       
x:Name="GroupList" ItemsSource="{Binding XPath=Source}">
           

               

                   
IsItemsHost="True">

                   

               

           

           

               

                   

                       
Source="images/source.png" />
                       
Text="{Binding XPath=@Title}" HorizontalAlignment="Center" />
                   

               

           

       

   


SourceManager.xaml:

  x:Class="LawBib.SourceManager"
             
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             
mc:Ignorable="d"
             
d:DesignHeight="300" d:DesignWidth="300" Background="#f5f7f8">
   

       

           

               
Source="Resources.xaml" />
               
Source="Templates.xaml" />
           

       

   

...