I have a List View in which I have defined a custom cell as a user control.
In the custom cell I given user hyperlink, I am showing a WPF dialog when user clicks on a hyperlink.
I want WPF dialog comes just above the hyperlink..
Please let me know how can I acheive this or how to set the location of the dialog so that it just comes above the hyperlink.
Centring Windows To open a new window and have it centred on the screen, set the WindowStartupLocation property to CenterScreen. You can do this using the XAML or in code before the window is displayed. Run the program and click the button to see the result.
When a Window is created at run-time using the Window object, it is not visible by default. To make it visible, we can use Show or ShowDialog method. Show method of Window class is responsible for displaying a window.
To package content for navigation, WPF provides the Page class. You can navigate from one Page to another declaratively, by using a Hyperlink, or programmatically, by using the NavigationService. WPF uses the journal to remember pages that have been navigated from and to navigate back to them.
Window.Left and Window.Top
var location = myTextBlock.PointToScreen(new Point(0, 0)); window.Left = location.X; window.Top = location.Y - window.Height;
You need to set the WindowStartupLocation
to Manual
(which is the default however) as well as setting the Top
and Left
property values.
Setting CenterScreen causes a window to be positioned in the center of the screen that contains the mouse cursor.
Setting WindowStartupLocation to CenterOwner causes a window to be positioned in the center of its owner window (see Owner), if specified. The owner window can be either another WPF window or a non-WPF window.
Source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With