[WPF] with Popup controls do floating window prompt box

Demand: When the mouse moved into an area, a floating pop-up window for the user to the next step.

15147010-de935099f7e7851e.png

<Border BorderBrush="Black" Width="60" Height="40" Margin="5" BorderThickness="1" Background="Yellow" MouseEnter="border_MouseEnter" >

        <Grid>

            <TextBlock Text = "multiple choice" HorizontalAlignment = "Center" VerticalAlignment = "Center" />

            <Popup Name="pop1" StaysOpen="False">

                <TextBox Background = "Green" Height = "98" Width = "233"> consider buying each other to open the domestic </ TextBox>

            </Popup>

        </Grid>

 </Border>

Backstage:

private void border_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)

{

pop1.IsOpen = false;

pop1.IsOpen = true;

}

Description: Why do I have IsOpen = false then IsOpen = false,

"After clicking elsewhere, pop1 not automatically shut down, but went the other went behind the controls so you let it open, it is already open, and has been in the back, so to see it. You let it off, then on again, and again went to the front. "


1. Common Property Description

IsOpen: Boolean value that indicates whether the control display Popup

StaysOpen: Boolean value that indicates when the Popup control loses focus, whether to close the Popup control display

PopupAnimation: Indicates if the display using the animation window, only when this property is equal to true AllowsTransparency be useful

Popup window itself is an invisible element to appear only after the information is placed on the window

Positioning the Popup targeting methods are generally not the same as the control, using five Popup property to set position information:

PlacementTarget: Popup definition set opposite control,

If no attribute is NULL, the Popup is positioned relative to the upper left corner of the screen

Placement: an enumeration value that specifies targeting Popup Controls

PlacementRectangle: setting a rectangle, when the Popup display control, a relative position of this rectangle to display the location of this rectangle is also with respect to the control attribute set PlacementTarget

HorizontalOffset: specify a desired value, indicating the position of the horizontal movement Popup number of pixels

VerticalOffset: Specifies a value indicating the desired vertical position of the Popup number of pixels moved

15147010-2f2691cef3e5886c.png

Reproduced in: https: //www.jianshu.com/p/2a45e92f4cad

Guess you like

Origin blog.csdn.net/weixin_33896726/article/details/91310227