Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7069679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:28:30+00:00 2026-05-28T05:28:30+00:00

I created a ContentTemplate and Style for the ToggleButton which looks like the one

  • 0

I created a ContentTemplate and Style for the ToggleButton which looks like the one you know from Microsoft’s WebMatrix.

However, it’s not always possible to click and the hover effect isn’t shown too.
I figured out that the click/hover area appears when I’m hovering over the icon or the text of my button.

Hover and click don't work

Hover and click work

Once hovered It’s possible to get back to right with the mouse and the hover doesn’t disappear (as it should).

Here’s the important part of the code:

            <StackPanel.Resources>
                <Style TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource NavigationButton}" />
            </StackPanel.Resources>
            <ToggleButton x:Name="_btn_Buchungen" Click="_btn_Buchungen_Click">
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                    <Image Source="{StaticResource Buchungen}" Width="16" Height="16" />
                    <TextBlock Text="Buchungen" />
                </StackPanel>
            </ToggleButton>

The ControlTemplate and Styles:

<Style TargetType="{x:Type ToggleButton}" x:Key="NavigationButton">
            <Setter Property="Background" Value="{x:Null}" />
            <Setter Property="Height" Value="35" />
            <Setter Property="BorderBrush" Value="{x:Null}" />
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                        <Border Name="OuterBorder" BorderThickness="0,1,0,0" >
                            <Border Name="InnerBorder" BorderThickness="0,1,0,1" >
                                <ContentPresenter HorizontalAlignment="Left" VerticalAlignment="Center"/>
                            </Border>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter Property="Style" TargetName="InnerBorder" Value="{StaticResource ButtonInnerBHover}" />
                                <Setter Property="Style" TargetName="OuterBorder" Value="{StaticResource ButtonOuterBHover}" />
                            </Trigger>
                            <Trigger Property="IsChecked"  Value="true">
                                <Setter Property="Style" TargetName="InnerBorder" Value="{StaticResource ButtonInnerBHover}" />
                                <Setter Property="Style" TargetName="OuterBorder" Value="{StaticResource ButtonOuterBHover}" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Resources>
                <Style TargetType="{x:Type TextBlock}">
                    <Setter Property="TextAlignment" Value="Left" />
                    <Setter Property="Margin" Value="10, 0,0,0" />
                    <Setter Property="Effect">
                        <Setter.Value>
                            <DropShadowEffect BlurRadius="1" Direction="270" ShadowDepth="1" Color="White" />
                        </Setter.Value>
                    </Setter>
                </Style>
                <Style TargetType="{x:Type StackPanel}">
                    <Setter Property="Margin" Value="20,0,0,0" />
                </Style>
            </Style.Resources>
        </Style>

The ToggleButton’s hover should be shown when you are mouse over the full width of the button itself and should also be clickable.

I tried t fix it with different properties like horizontal stretching and IsHitTestVisible but I didn’t get it yet. Any idea?

Already saw this thread and tried different things with the solution but couldn’t figure it out. Problem with the mouse click on toggleButton in WPF

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:28:31+00:00Added an answer on May 28, 2026 at 5:28 am

    Set the Background of the outermost control in the template to Transparent, that way it should hit-test, no matter what the content is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanted to know which one amongst Style and UserControl would be better to
I created a style and controltemplate for my ComboBox and I would like to
Created .NET WCF service, tested it - works. Generated schemas from Data and service
I created a program using dev-cpp and wxwidgets which solves a puzzle. The user
Let's say I've created a UserControl with the following ContentTemplate defined in XAML: <UserControl.ContentTemplate>
I created a FlatCombo Style that I want to apply to a combo box.
I created a few mediawiki custom tags, using the guide found here http://www.mediawiki.org/wiki/Manual:Tag_extensions I
I created a single page (with code behind .vb) and created Public intFileID As
I created an Interop user control in VS2005. When the user control is shown
I created a simple .NET windows application in Visual Studio 2005 and on just

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.