Quantcast
Viewing all articles
Browse latest Browse all 256

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

Viewing all articles
Browse latest Browse all 256

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>