Button Click Event After Control Template RRS feed

  • Question

  • I have a template for a button as below:

    <Style x:Key="CloseButtonStyle" TargetType="{x:Type Button}">
       <Setter Property="Margin" Value="2" />
       <Setter Property="Width" Value="28" />
       <Setter Property="Height" Value="28" />
       <Setter Property="Template">
    	<ControlTemplate TargetType="{x:Type Button}">
          <Grid >
           <Path Data="M38,-2 L78,38" Stretch="Fill" Stroke="#FF505050" StrokeThickness="3" Width="15" Height="15"/>
           <Path Data="M38,38 L78,-2" Stretch="Fill" Stroke="#FF505050" StrokeThickness="3" RenderTransformOrigin="1,1" Width="15" Height="15"/>

     Now i have applied the template to a button as below:



    Button Style="{DynamicResource CloseButtonStyle}" Click="Button_Click" />

    Question ) The click event does not fire. However if for the above Grid in the control template i add Background="Transparent" then the click event does fire. I am sure i am missing some fundamental understaning, what is that?

    Wednesday, May 4, 2011 8:25 PM


All replies