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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:26:02+00:00 2026-06-17T09:26:02+00:00

It took me hours to figure out the answer to this question, so I

  • 0

It took me hours to figure out the answer to this question, so I thought I would write an FAQ or answer for what I found. (it is based on the following thread Binding Textbox IsFocused to Popup IsOpen plus additional conditions)

I found lots of examples of binding popups to things like toggle buttons and other things that are based on windows chrome and have built in triggers. But in my application I wanted to bind a popup to a simple rectangle with a custom brush fill. I could not find an example on how to have a popup open ans stay open when a user mouses over the rectangle.

So I am posting this question and I will immediately post the answer I found so that hopefully someone else can benefit from it. I will also mark an answer for anyone who can help me understand if stackoverflow allows posts like this, or a better way I could have gone about it.

EDIT 1)

I can’t self answer for 8 hours so here is the working code:
the following is a simple example of how to use the popup on a basic UIElement like a rectangle/ellipse/etc…

<Grid HorizontalAlignment="Stretch" Height="Auto">
    <Rectangle x:Name="PopupRec"
               Grid.Row="0"
               Width="20" Height="20"
               HorizontalAlignment="Right" 
               Fill="Gray" Margin="0,0,0,10" />
    <Popup x:Name="SortPopup" 
           PlacementTarget="{Binding ElementName=PopupRec}" 
           StaysOpen="False" 
           PopupAnimation="Slide" 
           AllowsTransparency="True">
        <Border Background="White" Padding="15">
            <StackPanel Orientation="Vertical">
                <Button Command="{Binding MyCommand}" CommandParameter="5">5</Button>
                <Button Command="{Binding MyCommand}" CommandParameter="10">10</Button>
                <Button Command="{Binding MyCommand}" CommandParameter="15">15</Button>
                <Button Command="{Binding MyCommand}" CommandParameter="20">20</Button>
            </StackPanel>
        </Border>
        <Popup.Style>
            <Style TargetType="{x:Type Popup}">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding ElementName=PopupRec, Path=IsMouseOver}" Value="True">
                        <Setter Property="IsOpen" Value="True" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding ElementName=SortPopup, Path=IsMouseOver}" Value="True">
                        <Setter Property="IsOpen" Value="True" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </Popup.Style>
    </Popup>
</Grid>

Just paste this inside window/usercontrol/etc…

  • 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-06-17T09:26:03+00:00Added an answer on June 17, 2026 at 9:26 am

    I’d suggest the following improvement. It would make the Popup Style independent of any element names, and would thus enable you to use it as a default Style by putting it into the Window’s or UserControl’s Resources.

    <Style TargetType="{x:Type Popup}">
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=IsMouseOver,
                                   RelativeSource={RelativeSource Self}}"
                         Value="True">
                <Setter Property="IsOpen" Value="True" />
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=PlacementTarget.IsMouseOver,
                                   RelativeSource={RelativeSource Self}}"
                         Value="True">
                <Setter Property="IsOpen" Value="True" />
            </DataTrigger>
        </Style.Triggers>
    </Style>
    

    And please note that a Rectangle is not a “basic UIElement”. It’s a Shape, which itself is a FrameworkElement.

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

Sidebar

Related Questions

It took me hours to figure out how to implement a timer into my
Really odd experience with this which took me over an hour to figure out.
I have been trying to figure this out for a few hours now, using
I took a look at this answer and it goes in part to solving
Nearly took me 4 hours to even get to this point. I really just
I took many hours trying to solve this problem I have attempted, without success.
it took me some time to find out that both Eclipse and Aptana get
I took over an old HTML based site with all hard coded links, no
I modified a simple image slider in jsfiddle and can't figure out why I
I have a problem , I took me 2 hours but I couldn't solve

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.