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

  • Home
  • SEARCH
  • 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 6710763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:03:34+00:00 2026-05-26T08:03:34+00:00

i have he following expander toggle button style, that is visually getting closer to

  • 0

i have he following expander toggle button style, that is visually getting closer to what I want but it does not respond properly clicks. When you click on it to expand or collapse, it does not always respond. Any ideas? TIA.

       <ControlTemplate x:Key="ExpanderToggleButton"
         TargetType="ToggleButton">
            <Canvas Width="14" Height="14">
                <Rectangle Stroke="Gray"  
                           RenderOptions.EdgeMode="Aliased" 
                           StrokeThickness="1"  Width="14" Height="14" 
                           Canvas.Left="0" Canvas.Top ="0"/>
                <Path RenderOptions.EdgeMode="Aliased" 
                          Name="ExpandPath" 
                          Stroke="Black" 
                          Margin="0" 
                          StrokeThickness="1" 
                          Data="M 5 1 L 5 9 M 1 5 L 9 5" 
                      Canvas.Left="2" Canvas.Top ="2"/>            
            </Canvas>
            <ControlTemplate.Triggers>
                <Trigger Property="IsChecked" Value="True">
                    <Setter Property="Data" TargetName="ExpandPath"
                              Value="M 1 5 L 9 5"/>
                </Trigger>                   
            </ControlTemplate.Triggers>
        </ControlTemplate>
        <!-- Expander style -->
        <Style TargetType="Expander">                
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Expander">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Name="ContentRow" Height="0"/>
                            </Grid.RowDefinitions>                              
                            <Border 
                                Name="Border" 
                                Grid.Row="0"                                    
                                BorderThickness="1" 
                                CornerRadius="4,4,0,0" >
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="15" />
                                        <ColumnDefinition Width="*" />
                                     </Grid.ColumnDefinitions>
                                    <ToggleButton
                                        Grid.Column="0"
                                        IsChecked="{Binding Path=IsExpanded, 
                                                            Mode=TwoWay,
                                        RelativeSource={RelativeSource
                                                            TemplatedParent}}"
                                        OverridesDefaultStyle="True" 
                                        Template="{StaticResource 
                                                 ExpanderToggleButton}" />
                                    <ContentPresenter 
                                        Grid.Column="1"
                                        Margin="4" 
                                        ContentSource="Header" 
                                        RecognizesAccessKey="True" />
                                </Grid>
                            </Border>
                            <Border 
                                Name="Content" 
                                Grid.Row="1"                                    
                                BorderThickness="1,0,1,1" 
                                CornerRadius="0,0,4,4" >
                                <ContentPresenter Margin="4" />
                            </Border>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsExpanded" Value="True">
                                <Setter TargetName="ContentRow" Property="Height"
                                        Value="{Binding 
                                        ElementName=Content,Path=DesiredHeight}" />
                            </Trigger>                             
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
  • 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-26T08:03:35+00:00Added an answer on May 26, 2026 at 8:03 am

    Set the background of the Canvas in the ControlTemplate to “Transparent”:

    <ControlTemplate x:Key="ExpanderToggleButton"
        TargetType="ToggleButton">
    
        <!-- The canvas needs a background to work properly with clicks,
             so set it to Transparent -->
        <Canvas Width="14" Height="14" Background="Transparent">
            <Rectangle Stroke="Gray"  
                        RenderOptions.EdgeMode="Aliased" 
                        StrokeThickness="1"  Width="14" Height="14" 
                        Canvas.Left="0" Canvas.Top ="0"/>
            <Path RenderOptions.EdgeMode="Aliased" 
                        Name="ExpandPath" 
                        Stroke="Black" 
                        Margin="0" 
                        StrokeThickness="1" 
                        Data="M 5 1 L 5 9 M 1 5 L 9 5" 
                    Canvas.Left="2" Canvas.Top ="2"/>
        </Canvas>
        <ControlTemplate.Triggers>
            <Trigger Property="IsChecked" Value="True">
                <Setter Property="Data" TargetName="ExpandPath"
                            Value="M 1 5 L 9 5"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    

    When there is no canvas background you have to click exactly on the path (the + or the -) to get the click to register. With the canvas background you can click anywhere on the canvas.

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

Sidebar

Related Questions

I have an accordion that I want to have the following functionality: when the
I have the following code: JS Fiddle I want that on hover the background
I have the following code. I need help fixing it such that the Category
I have following code in my MVC2 view: <tr class=edit style=display:none> <td> <%= Html.DropDownList(drpFields,
I have following code in my MVC2 view: <tr class=edit style=display:none> <td> <%= Html.DropDownList(drpFields,
I have the following html that when a user selects leasehold additional form fields
Using Firebug I have found that the Dynatree plugin changes the following code: <li
I have following situation: I have loged user, standard authentication with DB table $authAdapter
I have following string String str = replace :) :) with some other string;
I have following foreach-loop: using System.IO; //... if (Directory.Exists(path)) { foreach(string strFile in Directory.GetFiles(path,

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.