Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
as you see in following code. I create a popup one time with child and other time without child.

the problem is they open in different places.

note: this happens in some laptops(PC) not all of them.

my laptop = ZenBook model:UX303L (Windows 8.1)

Result Picture

my code:
C#
public MainWindow()
{

    InitializeComponent();
    CreatePopup(true);
    CreatePopup(false);
}

private void CreatePopup(bool hasChild)
{
    Popup popup = new Popup();
    popup.Width = 200;
    popup.Height = 200;
    popup.HorizontalOffset = 500;
    popup.VerticalOffset = 50;

    if (hasChild)
    {
        var tb = new TextBlock() { Text = "TextBlock1", Background =
                                 Brushes.Yellow, Width = 200, Height = 200 };
        tb.FlowDirection = FlowDirection.LeftToRight;
        popup.Child = tb;
    }

    popup.StaysOpen = true;
    popup.IsOpen = true;
}


What I have tried:

this is weird problem and i dont know why.
hope somebody answer me.
Posted
Updated 1-Jun-16 19:07pm
v2
Comments
VR Karthikeyan 2-Jun-16 2:19am    
Is Popup your own implementation of a WPF Window? or Are you referring this from any library? because WPF Window doesn't have HorizontalOffset and VerticalOffset properties. If you are using a WPF window, then set it's WindowStartupLocation property to CenterScreen.
Peter_in_2780 2-Jun-16 3:22am    
It lives in System.Windows.Controls.Primitives, according to MSDN https://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.popup%28v=vs.110%29.aspx
Member 10527566 5-Jun-16 0:34am    
@Peter_in_2780 2
tnx but I did'nt see where mention my problem!
Peter_in_2780 5-Jun-16 5:56am    
I was replying to VR Karthikeyan, seeing he didn't know where Popup came from.
Member 10527566 5-Jun-16 0:14am    
@VR Karthikeyan
i used System.Windows.Controls.Primitives.Popup

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900