How to have toolwindow resize when content resized

Docking/MDI for WPF Forum

Posted 5 years ago by Hank Drews
Version: 14.2.0610
Avatar

I'm using the EditorSearchView inside of a ToolWIndow that I float when the the "Find" command is executed.   I have no problem doing that.   However, the EditorSearchView control can shrink and grow depending upon whether or not the search options are expanded or collapsed.   I want the ToolWindow to expand/collpase automatically.   With a normal window you can do that by setting the SizeToContent to WidthAndHeight.   Here is how I'm defining the ToolWindow:

privatevoidCreateFindReplaceToolWindow(SyntaxEditor editor, bool find) {

var editorSearchview = newEditorSearchView();

ImageSource image;

if(find) {

image =

newBitmapImage(

newUri(@"pack://application:,,,/PLIDE;component/Images/Find.png", UriKind.RelativeOrAbsolute));

editorSearchview.

Mode = EditorSearchMode.Find;

}

else {

image =

newBitmapImage(

newUri(@"pack://application:,,,/PLIDE;component/Images/Replace.png", UriKind.RelativeOrAbsolute));

editorSearchview.

Mode = EditorSearchMode.Replace;

}

editorSearchview.

SyntaxEditor = editor;

var window = newToolWindow(DockingSite, "FindReplace", "Find/Replace", image, editorSearchview) {

CanAttach =

true,

CanAutoHide

=

true,

CanBecomeDocument

=

false,

CanDockLeft

=

true,

CanDockRight

=

true,

CanDockTop

=

false,

CanDockBottom

=

false,

CanRaft =

true,

CanMaximize

=

false

};

window.

Float(FloatSizingBehavior.SizeToContent);

}

 

The initial size of the window is correct, but when I expand the underlying control, the window does not resie as well.   Anyway to make that happen?

Comments (6)

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Hank,

I don't believe we have anything that will kick it in automatically but you can programmatically call ToolWindow.Float(FloatSizingBehavior.SizeToContent) and that should resize the rafting window, even if it was already rafted.


Actipro Software Support

Posted 5 years ago by Hank Drews
Avatar

Thanks I'll give that a try.

Posted 5 years ago by Hank Drews
Avatar

That worked thanks.

Posted 4 years ago by Jan Schiefer
Avatar

I am trying to do this also, but a few things don't seem to work quite right:

  • When reissuing the ToolWindow.Float(), I am getting an ArgumentException: "Hwnd of zero is not valid."
  • The outline and background of the old ToolWindow is still visible
  • Even calling InvalidateVisual() on the ToolWindow doesn't clean it up,

Is there something else I need to do to make this work properly? In a nutshell, when the window is rafted, I need to be able to go back and forth between FloatSizingBehavior.SizeToContent and FloatSizingBehavior.Default, as well as occasionally refresh. Is this possible?

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Jan,

We're not aware of any issues with the method described above.  If the exception is mentioning "hwnd" then that is pretty low level (Windows API).

If you are seeing a problem, please make a new simple sample project that shows the issue and email that to our support address.  Be sure to reference this thread and rename the .zip file extension of what you send so it doesn't get spam blocked.  Thanks!


Actipro Software Support

Posted 4 years ago by Jan Schiefer
Avatar

OK, thanks, I will try and isolate it to a small example and submit to support. Meanwhile, here's a stack trace (from 15.1.622):

System.ArgumentException occurred
HResult=-2147024809
Message=Hwnd of zero is not valid.
Source=PresentationCore
StackTrace:
at System.Windows.Interop.HwndSource.CriticalFromHwnd(IntPtr hwnd)
at ActiproSoftware.Windows.Controls.Docking.Primitives.RaftingWindow.OnSourceInitialized(EventArgs e)
at System.Windows.Window.CreateSourceWindow(Boolean duringShow)
at System.Windows.Window.CreateSourceWindowDuringShow()
at System.Windows.Window.SafeCreateWindowDuringShow()
at System.Windows.Window.ShowHelper(Object booleanBox)
at System.Windows.Window.Show()
at ActiproSoftware.Windows.Controls.Docking.Primitives.RaftingWindow.ActiproSoftware.Windows.Controls.Docking.Primitives.IRaftingWindow.Show()
at ActiproSoftware.Windows.Controls.Docking.DockSite.RaftCore(#ki notifier, DependencyObject control, Nullable'1 position, Nullable'1 size, FloatSizingBehavior behavior, Boolean isDrag)
at ActiproSoftware.Windows.Controls.Docking.DockSite.Raft(DependencyObject control, Nullable'1 position, Nullable'1 size, FloatSizingBehavior behavior, Boolean isDrag)
at ActiproSoftware.Windows.Controls.Docking.DockSite.Raft(DependencyObject control, Nullable'1 position, FloatSizingBehavior behavior, Boolean isDrag)
at ActiproSoftware.Windows.Controls.Docking.DockingWindow.Float(FloatSizingBehavior behavior)
at <my code>

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.