views:

19

answers:

1

If I have a Control with template like this:

 <Style x:Key="HomeButtonStyle" TargetType="{x:Type Control}" >
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate>
                <StackPanel VerticalAlignment="Top">
                    <Rectangle Width="20" Height="50" x:Name="PART_Rectangle" />
                    <ed:RegularPolygon x:Name="PART_Triangle" PointCount="3" 
                           Height="8" >
                    </ed:RegularPolygon>
                </StackPanel>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

Now, how to fire some sort of event when the PART_Rectangle clicked? And how that would be distinguished from the clicks on PART_Triangle?

A: 

Oh... I figured out. for example like that:

     private void Control_MouseDown(object sender, MouseButtonEventArgs e)
    {
       if( ((FrameworkElement)(e.OriginalSource)).Name == "PART_Rectangle")
       {
           //RectangleMouseDown 
      }
    }
Ike