Results 1 to 2 of 2

Thread: Does ControlTemplate break control functionality?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602

    Does ControlTemplate break control functionality?

    Hi!

    I am using a MenuButton from BetterWPF-controls in my project, but since it's looks dont fit ino our project, I wanted to change the appearance by using a ControlStyle to override the default looks:

    Code:
    <Style x:Key="TabListButtonStyle" TargetType="{x:Type b:MenuButton}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type b:MenuButton}">
                            <Border 
                                Name="Border"
                                BorderThickness="1" 
                                BorderBrush="{StaticResource C60Brush}"
                                Background="{StaticResource C80Brush}"
                                CornerRadius="3,3,0,0"
                                Margin="0,0,0,-1">
                                <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10,2,10,2">
                                    <TextBlock>A</TextBlock>
                                </Grid>
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter TargetName="Border" Property="Background" Value="WhiteSmoke"/>
                                </Trigger>
                                <Trigger Property="IsMouseOver" Value="False">
                                    <Setter TargetName="Border" Property="Background" Value="{StaticResource C80Brush}"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
    The problem is that after I apply this style nothing happens when I click on the button. A context menu should appear with the databound list of items.

    I seem to remember that I read that when using a Controltemplate (in contrast to a DataTemplate) none of the functionality will break, only the style will change. For example, if you change the standard button to a circle instead, you can still click on it, only it's looks have changed. Is there any reason why the MenuButton stopped working after I applied the above template?

    /Henrik

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602

    Re: Does ControlTemplate break control functionality?

    I solved this by removing the stuff from the style and added it in the control itself. Strange but it worked better...

    /H

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width