WindowClosing handler.

Docking/MDI for WPF Forum

Posted 4 years ago by Chris Jasniewski - Consultant, BNP Paribas
Version: 19.1.0686
Avatar

Have below error. How to fix that?

error CS0123: No overload for 'dockSite_WindowClosing' matches delegate 'EventHandler<DockingWindowsEventArgs>'

Comments (16)

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

Hello,

If you are upgrading from the pre-2016.1 codebase of Docking/MDI, you'll want to look at the Docking/MDI's "Converting to 2016.1" topic in the documentation that comes with the product.  That walks through the main breaking changes for things that were renamed or updated.  

Part of that topic explains how the WindowClosing event was removed and replaced with a WindowsClosing event.  The event args for that new event is DockingWindowsEventArgs.


Actipro Software Support

Posted 4 years ago by Chris Jasniewski - Consultant, BNP Paribas
Avatar

I have DockingWindowsDeserializingEventArgs e coming with nullified Tag and Name field. All other fields are set.

What can cause that? 

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

The e.Window can be null if:

  1. A SerializationId is specified but no matching docking window is found as current registered in the DockSite.
  2. A Name is specified but no matching docking window is found as current registered in the DockSite.
  3. No SerializationId or Name is specified.
  4. The serializer.ToolWindowDeserializationBehavior is not AutoCreate.

It sounds like perhaps you're running into #1 or #3. 

If #1, then you perhaps don't have a matching docking window with the same SerializationId already registered with the DockSite.


Actipro Software Support

Posted 4 years ago by Chris Jasniewski - Consultant, BNP Paribas
Avatar

I have SerializationID and started using it instead of Name, which is not present in saved XML layout. But i still have Tag==null in below event:

private void OnLayoutSerializerDockingWindowDeserializing(object sender, DockingWindowDeserializingEventArgs e)
{
// The e.Node property contains the XML data. The e.Window property contains the associated DocumentWindow or ToolWindow, if any. The
// window may have been retrieved from the DockSite, or automatically created (when using DockingWindowDeserializationBehavior.AutoCreate).
// For the latter case, the e.Window property can be set to a new window. In both cases, any properties can be set.
//kj685 changed to SerializationId fron Name as it has higher priority per ActiPro 19.1.685 doc.
if (e.Node.SerializationId.StartsWith("usr"))
{
if (!this.InitializeRCPToolWindow(e.Window as RCPWidgetWindow, e.Node.SerializationId, (XmlRCPWidgetWindow)e.Node.Tag))
{
e.Node.IsOpen = false;
e.Window.Destroy();
e.Window = null;
}
}
}

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

I don't believe our serialization code does anything with the Node.Tag property.  I believe it's just there for you to pass custom data around in on your own.  I looked in our old pre-2016.1 codebase and we didn't do anything with it there either.


Actipro Software Support

Posted 4 years ago by Chris Jasniewski - Consultant, BNP Paribas
Avatar

Great! I fixed that customized tag when noticed that i need to use SerializaztionId instead of name from serialized layout XML.

Now when i LoadFromString () mine tabbed window is at minimal size one line very short like : XXXXXXXXX in Top Left corner.

I noticed that ContainerDockedSize is present in XM<L and loaded:ContainerDockedSize="574.5,0"

Maybe value is wrong here (0 for height)

Pease advise,

Chris

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

Hi Chris,

It's hard to say without having something to debug with that shows how that ContainerDockedSize was set.  I wouldn't think that a ContainerDockedSize should have any zero values since that would cause it to be short or narrow.  That being said, an actual container's DockedSize might have a zero value if it's currently hidden in the layout due to a tool window being closed while in it.  But docking windows themselves probably shouldn't have zero values.  Nothing should have changed in that regard between the pre-2016.1 codebase and now.


Actipro Software Support

Posted 4 years ago by Chris Jasniewski - Consultant, BNP Paribas
Avatar

Actually ContainerDockSize is set properly.  Window display in proper size (300, 500),  but content (fields, labels, background color) is only in left top corner leaving all screen besided that left corner blank (white).  Do i miss attribute ? Do i need to save to XML more information?  Same window when displayed not from loadFromString layout, but when clicked on the menu shows properly.

XML:

+<ToolWindow UniqueId="506ba000-85cc-4439-92fc-e96ec8af39fc" ContainerDockedSize="748,498" Type="BNPParibas.CB.RCP.Infrastructure.Interfaces.RCPWidgetWindow, BNPParibas.CB.RCP.Infrastructure" State="Docked" LastActiveDateTime="2020-08-26T11:13:01.7168438-04:00" IsOpen="true" SerializationId="usrCBMultiViewControl_850a97a8_ecfc_4c21_9db0_8789b1042432">

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

The layout serialization just determines how the docking windows and their containers will be positioned after layout load.  The content within docking windows themselves should stretch to fill the docking window by default. 

If you aren't seeing that, then perhaps you've set HorizontalAlignment and VerticalAlignment properties or Margin properties incorrectly on your content elements.  But that kind of thing is something you do in XAML and not in layout serialization.


Actipro Software Support

Posted 4 years ago by Chris Jasniewski - Consultant, BNP Paribas
Avatar

What might be wrong with this code?

<docking:DockSite x:Name="dockSite" AreDocumentWindowsDestroyedOnClose="False" CanDocumentWindowsFloat="True"
Width="Auto" WindowsClosing="dockSite_WindowClosing" ToolWindowsTabStripPlacement="Bottom" ToolWindowsTabOverflowBehavior="ShrinkWithMenu" WindowsClosed="dockSite_WindowClosed">
<!-- kj685 end -->

<docking:SplitContainer Name="spltContainer" Orientation="Vertical">
<docking:Workspace x:Name="wspMain" >
<docking:TabbedMdiHost Name="tabMDIMain" HasTabCloseButtons="True" TabOverflowBehavior="ScrollWithMenu" >
<!-- <docking:TabbedMdiContainer Name="tabMDIContainer" /> -->
</docking:TabbedMdiHost>
</docking:Workspace>
<!--kj685 start -->
<docking:ToolWindowContainer>
<docking:ToolWindow x:Name="toolWindowsToolWindow" ContainerMinSize="500,500" ContainerMaxSize="1000,1000" ContainerDockedSize="500, 750" >
</docking:ToolWindow>
</docking:ToolWindowContainer>
<!-- kj685 end -->
</docking:SplitContainer>
<docking:DockSite.Switcher>
<docking:SimpleSwitcher IsTabStop="False" Name="simpleSwitcher" />
</docking:DockSite.Switcher>

</docking:DockSite>

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

Hello,

I don't really see anything wrong with that code.  You might want to remove the Width="Auto" from the DockSite and remove the commented out TabbedMdiContainer.  You should never name TabbedMdiContainer or ToolWindowContainer instances since those are transient and are created/destroyed as layout changes occur.  The rest looks fine.


Actipro Software Support

Posted 4 years ago by Chris Jasniewski - Consultant, BNP Paribas
Avatar

I now see restored window from saved layout after i set toolWindow.Width and Height,  but when window is tabbed it does not stretch horizontally.  It is on left with hardcoded width.  Below is a code sample:

if (oWidget != null)
{
mySize.Height = 500; mySize.Width = 750;
}
toolWindow.Width = mySize.Width;
toolWindow.Height = mySize.Height-40;
toolWindow.ContainerDockedSize = mySize;
toolWindow.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
toolWindow.VerticalAlignment = System.Windows.VerticalAlignment.Top;

When i did toolWindow.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch winows when tabbed appeared in the center.

Old version of ActiPro do not need setting width and heigt after restring layout to properly display and tab window.

What do I miss here?

Chris

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

Hi Chris,

What you are doing there might be the exact cause of the problems you are seeing.  You are setting the Width/Height/HorizontalAlignment/VerticalAlignment properties on the ToolWindow.  None of those should ever be set on any docking windows or their containers since doing so will prevent our layout logic from working correctly.  Always leave any Docking/MDI controls within DockSite their default Width/Height/HorizontalAlignment/VerticalAlignment property values.  The same was true in all past versions as well.  Only set the ContainerDockedSize property since that will give our logic a hint on how to arrange things.


Actipro Software Support

Posted 4 years ago by Chris Jasniewski - Consultant, BNP Paribas
Avatar

When I do that restored screen have proper docking size, but content width and height is minimal.  That way works with older actipro, but new do not save something in XML

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

The docking windows will stretch their content to fill by default.  That is unless you have something that is overriding it (implicit styles you've defined that might do so) or have things like specific Width/Height/HorizontalAlignment/VerticalAlignment set on the child control of the docking windows.  Nothing has changed with that between old and new versions.

If you can put together a new sample sample project that shows the issue you're having, please send that over and we can debug it to see where things are going wrong.  That is probably the best next step and will help us solve the issue.  Email our support address with a ZIP of the sample, mention this thread, and be sure to exclude any bin/obj folders from the ZIP you send.  You should be able to repro this by having similar docking windows defined with the same SerializationIds and then put a mockup of similar content in one of them to mimic what's happening in your real app.  Thanks!


Actipro Software Support

Posted 4 years ago by Chris Jasniewski - Consultant, BNP Paribas
Avatar

I fixed it.  You was right. No setting Width and Height neccessary.  It happened that i had generic widget with:

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Height="22" Width="135"
HorizontalAlignment="Stretch" VerticalAlignment="Top" ContainerMinSize="100, 200">

After I removed all is at suppose to be.

Thanks,

Chris

The latest build of this product (v24.1.2) was released 12 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.