0

I want to open a Window via ShowDialog() in a WPF application and it should show exactly above two controls in the application's MainWindow.

I can position the Window correctly in terms of X and Y / Top and Left but I cannot get the height and width to match the controls underneath. The Window is always showing narrower and shorter.

I am using the following code:

Private Sub Button_Click_1(sender As Object , e As RoutedEventArgs)

  Me.UpdateLayout()
  Me.sbmSideBarManager.UpdateLayout()
  Me.sbcFolders.UpdateLayout()
  Me.sbcFilters.UpdateLayout()

  Dim lVisiblePropertiesDialog As New VisiblePropertiesDialog 

  Dim lSideBarManagerPoint As Point = Me.sbmSideBarManager.TranslatePoint(New Point(0,0), Me.sbmSideBarManager)
  Dim lSideBarManagerLocation As Point = Me.sbmSideBarManager.PointToScreen(lSideBarManagerPoint)


  lVisiblePropertiesDialog.WindowStartupLocation = Windows.WindowStartupLocation.Manual
  lVisiblePropertiesDialog.Top = lSideBarManagerLocation.Y
  lVisiblePropertiesDialog.Left = lSideBarManagerLocation.X
  lVisiblePropertiesDialog.Height = Me.sbmSideBarManager.ActualHeight
  lVisiblePropertiesDialog.Width = (Me.sbcFolders.ActualWidth + Me.sbcFilters.ActualWidth)

  lVisiblePropertiesDialog.ShowDialog()

End Sub

miriyo
  • 103
  • 1
  • 11
  • Width and height include the size of the borders and the window caption. But you care about the client area size when you want controls to fit. [Read this](http://stackoverflow.com/questions/1081580/how-to-set-wpf-windows-startup-clientsize). – Hans Passant Mar 07 '16 at 14:15
  • Thank you. That'll help me when calculating the space needed to remove border area etc but I need the real ActualWidth and ActualHeight of the controls in my MainWindow and the properties with the same names are giving me something else. – miriyo Mar 07 '16 at 15:59

0 Answers0