I’m working on a project where I have to add a small preview pane and a about box whenever a user is hovering the buttons on the main window.
For the examlpe: I have a window – preview.xaml, and my main window called MainWindow.xaml.
How do I set the preview windows bottom to appear on the top of button1 on the MainWindow?
I tried something like this without any luck:
public preview()
{
InitializeComponent();
this.WindowStartupLocation = WindowStartupLocation.Manual;
Top = mainWindow.button1.Margin.Top;
}
I hope my ramblings makes any sense…
Any help is greatly appreciated!
You need to set
LeftandTopwindow properties to screen coordinates, button margins won’t help here. UsePointToScreenfunction to obtain screen coordinates of your buttons: