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 6972051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:55:06+00:00 2026-05-27T16:55:06+00:00

I want a button that is an ellipse with a centered ‘x’ that will

  • 0

I want a button that is an ellipse with a centered ‘x’ that will change it’s colours on mouse over (both the colour of the ‘x’ and that of the ellipse).

Similar to this
enter image description here

The following gets the standard appearance I want

    <Grid>
    <Grid.Resources>
        <Style x:Key="CloseButtonBackgroundStyle" TargetType="{x:Type Ellipse}">
            <Setter Property="Width" Value="25" />
            <Setter Property="Height" Value="25" />
            <Setter Property="Fill" Value="#f4f4f4" />
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Fill" Value="Red" />
                </Trigger>
            </Style.Triggers>
        </Style>

        <Style x:Key="CloseButtonForegroundStyle" TargetType="{x:Type TextBlock}">
            <Setter Property="Foreground" Value="#898989" />
            <Setter Property="HorizontalAlignment" Value="Center" />
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="FontSize" Value="16" />
            <Setter Property="Padding" Value="0 0 0 4" />

            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Foreground" Value="#f9ebeb" />
                </Trigger>
            </Style.Triggers>
        </Style>            
    </Grid.Resources>

    <Ellipse Style="{StaticResource CloseButtonBackgroundStyle}" />

    <TextBlock Text="x"
               Style="{StaticResource CloseButtonForegroundStyle}"/>
</Grid>

The trouble is using the IsMouseOver property. It does work but only for each control. i.e. when I’m over the ellipse the background turns red BUT when I then go over the textblock the ellipse is no longer mouse over and so it turns back to the standard fill colour.

Do I need to change my approach so that the content of the ellipse is the textblock?

Many thanks

  • 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-27T16:55:06+00:00Added an answer on May 27, 2026 at 4:55 pm

    The issue is that the TextBlock actually covers more real estate than the ‘x’ because fonts have intrinsic padding around the pixels that form the letter. So the mouse could actually be over the TextBlock (and not just the pixels of the ‘x’ character) and this would prevent your other trigger from firing. This would account for the either/or effect you are experiencing.

    Among other approaches, one possibility is to wrap both elements into a control template…

    <Grid>
        <Grid.Resources>
            <ControlTemplate x:Key="EllipseWithText" TargetType="{x:Type Button}">
                <Grid x:Name="MainGrid">
                    <Rectangle x:Name="MainRectangle" Fill="#00000000" RadiusX="5" RadiusY="5"/>
                    <ContentPresenter x:Name="Presenter" 
                                  HorizontalAlignment="Center"  VerticalAlignment="Center" 
                                  TextBlock.Foreground="#BB225588"/>
                    <Path x:Name="Cross" Data="M0,0 L1,1 M0,1 L1,0" 
                                  Stretch="Fill" Stroke="Black" 
                                  StrokeThickness="2" Width="8" Height="8" />
                </Grid>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter TargetName="MainRectangle" Property="Fill" Value="Red"/>
                        <Setter TargetName="MainRectangle" Property="Stroke" Value="Transparent"/>
                        <Setter TargetName="Cross" Property="Stroke" Value="White" />
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Grid.Resources>
        <Button Height="15" Width="15" Template="{StaticResource EllipseWithText}"/>
    </Grid>
    

    This will give your desired effect of having the ellipse turn red and the ‘x’ turn a different colour. Note that this template does not use a TextBlock, but instead uses a Path. The Path simulates an ‘x’ character. This approach causes less real estate to collide and gives the effect you are after.

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

Sidebar

Related Questions

I want to create a button that has a jQuery click on the fly.
I want to make a button that starts my php script after I click
I want to have a button that has numbers in the range 0 ...
I want button in vertically, for that i can extend the height and shrink
I have a Login button that I want to be disabled until 3 text
In my Delphi Project i want to have a 'Settings' button that when clicked,
Suppose, I want to have a link or a button that when user click
I want to have a button on my toolbar that has a little down
I want to load the data into session so that when the next button
I have a datagrid that I want to add a button/s to at runtime.

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.