Floating Toolwindow sizing

Docking/MDI for WPF Forum

Posted 8 years ago by Mick George - Software Engineer, CNC Software, Inc.
Version: 11.1.0544

We are using an EditorSearchView control in a floating toolwidow for our find and replace view and everything is working fine except we are running into a little problem with resizing the tool window to fit the EditorSearchView control when the Quick Replace button is clicked (Default state is Quick Find).

To see this in action run your QuickStart\SearchCustomPatternProvider tear off the toolwindow and let it float, re-size the toolwindow to the Quick Find mode so that the Find Next button is visible. Now click the Quick Replace button to switch modes and the toolwindow does not automatically re-size to the EditorSearchControl but adds a vertical scroll bar to enable the user to bring the Quick Replace buttons into view.

My questions is, after a lot of testing, how can I programmatically re-size the toolwindow to fit the EditorSearchView control based on user selection so that no matter what mode is selected all applicable buttons are always in view without the need to display a vertical scroll bar or the user has to manually re-size the toolwindow?


Comments (1)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Mick,

Your best bet right now is to use the AnimatedExpanderDecorator.ExpansionAnimationCompleted event. You can attach it to the EditorSearchView like this:
<docking:ToolWindow x:Name="searchToolWindow" Title="Find and Replace" CanClose="False">
    <ScrollViewer VerticalScrollBarVisibility="Auto">
        <editor:EditorSearchView SearchOptions="{StaticResource EditorSearchOptions}" SyntaxEditor="{Binding ElementName=editor}"
                                    SearchPatternProviderFactory="{StaticResource CustomSearchPatternProviderFactory}"
Then in the code behind, you'd need to do something like this:
private int count = 0;
private void EditorSearchView_ExpansionAnimationCompleted(object sender, RoutedEventArgs e) {
    if (this.searchToolWindow != null && this.searchToolWindow.State == DockingWindowState.Floating) {
        this.Dispatcher.BeginInvoke((Action)(() => {
            if (this.count != 0) {
                this.count = 0;
        }), DispatcherPriority.Background);
Because the EditorSearchView uses a couple animated expanders the count is need to group those into a single call to the Float method. With the count part it would flicker.

We've added an associated CollapseAnimatedCompleted event for the next release, so you could size the window smaller when changing back to Quick Find (or collapsing the options).

We've also added an option to EditorSearchView to turn off the expansion animations, so the priority of the BeginInvoke can be increased (which reduces the flicker even more).

Actipro Software Support

The latest build of this product (v2018.1 build 0675) 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.