WindowsFormsHost is always the most top from WPF element

后端 未结 4 1578
长发绾君心
长发绾君心 2020-12-01 17:11

how to set the z-index windowsformhost that they are not always at the top of the WPF element ?

4条回答
  •  一向
    一向 (楼主)
    2020-12-01 17:15

    In my situation my WindowsFormsHost is in a two row Grid. The bottom row has a StackPanel in it that changes Height depending on what it contains. I handle that StackPanel's LayoutUpdated event to resize my WindowsFormsHost by subtracting it's ActualHeight from the Grid's ActualHeight. Be sure to use ActualHeight not Height.

         void ResizeWinhost()
        {
            mainGrid.UpdateLayout();
            detailPanel.UpdateLayout();
            winHost.Height = mainGrid.ActualHeight - detailPanel.ActualHeight - 5;
        }
    

提交回复
热议问题