Event handling for a button in a Silverlight DataGridColumnHeader
===

I have a Silverlight 5 project with a Styles.xaml and another class where I create a DataGrid at runtime. I want to have buttons in the DataGridColumnHeader to realize some kind of filter function. The style is defined as the following:

    <Style x:Key="DataGridFilterStyle" TargetType="sdk:DataGridColumnHeader">
        <Setter Property="ContentTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Grid Height="{TemplateBinding Height}" Width="Auto">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <StackPanel Orientation="Horizontal" Margin="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                            <TextBlock Text="{Binding}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0.2"/>
                            <Button Content="Foo" Margin="5,0" x:Name="filter" />
                        </StackPanel>
                    </Grid>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>

Then, I generate a DataGrid at runtime. I do not know the parent page because it's generic:

    dg = New DataGrid
    dg.AutoGenerateColumns = False
    dg.RowHeight = 28
    ' Doing some stuff here....
    dg.ColumnHeaderStyle = Application.Current.Resources("DataGridFilterStyle")
    gd.Children.Add(dg)  ' gd is a Grid as a parent container

So, I have my Styles.xaml and a separate class where I do some events. How can I add a click event to the buttons in my DataGridColumnHeader (filter)? Normally, it wouldn't be a problem if the style and the code are in the same file.

Thanks for any help!

Regards

Daniel