How to size the content of a docking window

Docking/MDI for WPF Forum

Posted 2 years ago by Michael Bayer
Version: 16.1.0633
Avatar

Hi,
following your MVVM samples, I have a few tool windows and document windows.
Also following your samples, I created a style to bind the properties of Actipro DockingWindow to my own class, which is called DockingWindowViewModelBase.

The style is stored in a resource dictionary and looks like

<Style x:Key="DockingWindowStyle" x:Name="DockingWindowStyle" TargetType="docking:DockingWindow">
   <Setter Property="Background" Value="{Binding Path=Background, Mode=TwoWay}"/>
   <Setter Property="BorderBrush" Value="{Binding Path=BorderBrush, Mode=TwoWay}"/>
   <Setter Property="BorderThickness" Value="{Binding Path=BorderThickness, Mode=TwoWay}"/>
   <Setter Property="CanAttach" Value="{Binding Path=CanAttach, Mode=TwoWay}"/>
   ... many other properties
</Style>

The DockingWindowViewModelBase replicates the most  original properties of the Actipro DockingWindow:

Public MustInherit Class DockingWindowViewModelBase
    Inherits ObservableObjectBase

    Private _background As Brush
    Private _borderBrush As Brush
    Private _borderThickness As Thickness
    Private _canAttach As Boolean?
    ...

     Public Overridable Property Background As Brush
        Get
            Return Me._background
        End Get
        Set(value As Brush)
            If Me._background IsNot value Then
                Me._background = value
                Me.NotifyPropertyChanged("Background")
            End If
        End Set
    End Property

    Public Overridable Property BorderBrush As Brush
        Get
            Return Me._borderBrush
        End Get
        Set(value As Brush)
            If Me._borderBrush IsNot value Then
                Me._borderBrush = value
                Me.NotifyPropertyChanged("BorderBrush")
            End If
        End Set
    End Property

    Public Overridable Property BorderThickness As Thickness
        Get
            Return Me._borderThickness
        End Get
        Set(value As Thickness)
            If Me._borderThickness <> value Then
                Me._borderThickness = value
                Me.NotifyPropertyChanged("BorderThickness")
            End If
        End Set
    End Property

    Public Overridable Property CanAttach As Boolean?
        Get
            Return Me._canAttach
        End Get
        Set(value As Boolean?)
            If Me._canAttach <> value Then
                Me._canAttach = value
                Me.NotifyPropertyChanged("CanAttach")
            End If
        End Set
    End Property

    ...

End Class

The tool windows and document windows are displayed at runtime, but their contents (the ViewModels) are just small rectangles and doesn't fill the whole range of the windows. Please have a look here.

Note: everything was working fine, before I created the style - but I need to access the properties.

Where do I go wrong?

Thank you in advance.

Michael

 

EDIT

I found out, that modifying the MinWidth/MaxWidth properties changes the size of the DocumentWindow content.

But how can I determine the correct values to ensure that the content (the ViewModel) fit closely in the Document Windows bounds - even if solution or the Document Window  size is changed? Should I take a exaggerated value like 100,000 to keep out of harm's way or what is the best practice?

Thank you.

Michael

 

EDIT 2

MinWidth isn't the solution.At the first glance it seems to work. But if I dock a ToolWindow at the left side, place a Grid in it with ColumnWidth="Auto", the width of the controls inside the Grid will be set to MinWidth.

More detailed:

I set MinWidth to 2000. I dock a ToolWindow on the left side and place a Grid in it. The Width-Property of the ColumnDefinition is "Auto". In this column, I place a ComboBox.

At runtime, I cannot see the Button of the ComboBox. If I open the ComboBox, I see, that its width exceeds the width of the ToolBox. The width of the ComboBox is the same as MinWidth -> 2000. Please look here.

So my question is again: how can I fit a DocumentWindows content to the bounds of this window?

Thank you.

Michael

[Modified 2 years ago]

Comments (2)

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

Hi Michael,

It doesn't require anything special to have content auto-size to the containing docking window.  Docking windows in the 2016.1 version are simple ContentControls in UI that contain their content and arrange it to the full size of the docking window.  You can see how in all our samples, we just indicate a child control and it auto-fills the full bounds of the docking window client area with nothing additional set.

The only time a child control wouldn't arrange to full size is if it had a specific Width/Height set (or Min/Max variations), if it had HorizontalAlignment or VerticalAlignment set, or if the control doesn't arrange to its available bounds.  I would suggest you look into things like those as the problem is likey in the configuration of whatever child control you are using.


Actipro Software Support

Posted 2 years ago by Michael Bayer
Avatar

You're right.

I've replicated all properties including Height/Width and the other properties you mentioned in your answer. I didn't set this properties to special values, but the default value of them is 0, which is a specific value.

I don't need this properties, so I remove them in my class and it works.

Thank you very much.

Michael

[Modified 2 years ago]

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.