Closing Designer in Code in custom save window

Stimulsoft Reports.WPF discussion
Post Reply
codemonkey
Posts: 15
Joined: Fri Jan 17, 2020 3:02 pm

Closing Designer in Code in custom save window

Post by codemonkey »

Hello,

i have a custom savehandler in which i open window where additional settings can be set and the report is saved into the database using this:

Code: Select all

AddHandler StiOptions.Engine.GlobalEvents.SavingReportInDesigner, AddressOf SaveReportHandler
I open the designer using

Code: Select all

ReportDesigner.DesignV2WithWpf()
In the handler the save dialog window is successfully opened.

Code: Select all

Private Sub SaveReportHandler(ByVal sender As Object, ByVal args As StiSavingObjectEventArgs)
Dim SpeichernDialog As New DesignerSpeichern()
If SpeichernDialog.ShowDialog() = DialogResult.OK Then
    args.Processed = True
    
    Dim test As New System.ComponentModel.CancelEventArgs
    test.Cancel = False
    StiOptions.Engine.GlobalEvents.InvokeClosingDesigner(ReportDesigner.Designer, test)
    Me.Close()
Else
    args.Processed = False
End If
End Sub
This works fine except one part the designer is still open.
How do i close the designer?
StiOptions.Engine.GlobalEvents.InvokeClosingDesigner(ReportDesigner.Designer, test) doesnt seem to work.
Lech Kulikowski
Posts: 7332
Joined: Tue Mar 20, 2018 5:34 am

Re: Closing Designer in Code in custom save window

Post by Lech Kulikowski »

Hello,

You can close the form with the designer component.

Thank you.
codemonkey
Posts: 15
Joined: Fri Jan 17, 2020 3:02 pm

Re: Closing Designer in Code in custom save window

Post by codemonkey »

Hello Lech,
thank you for the fast answer but i sadly dont understand it.

I looked through the ReportDesigner.Designer object for something recogniceable to close the window but could only find the InvokeClosingDesigner but that did nothing.
Can you please give me a line of code i can try?

Just for clarification:
Iam using the new WPF Components as our application moves away from winforms - with the winforms i got all that working.

When using ReportDesigner.DesignV2WithWpf() a new window is opened with the designer inside - it would also nice to open the designer into a panel or stackpanel instead of a new window but thats not cruical.
After clicking save or pressing ctrl+S my custom save window opens which is exactly as i want it to behave.
But after saving the report with my custom save window the designer stays open and has to be closed via the X on the right top.

Thanks again!
Lech Kulikowski
Posts: 7332
Joined: Tue Mar 20, 2018 5:34 am

Re: Closing Designer in Code in custom save window

Post by Lech Kulikowski »

Hello,

We need some additional time to investigate the issue, we will let you know about the result as soon as possible.

Thank you.
#15896
codemonkey
Posts: 15
Joined: Fri Jan 17, 2020 3:02 pm

Re: Closing Designer in Code in custom save window

Post by codemonkey »

Managed to solve it like this:

Code: Select all

Dim Parentobject = VisualTreeHelper.GetParent(ReportDesigner.Designer)
If Parentobject IsNot Nothing Then
    Parentobject = VisualTreeHelper.GetParent(Parentobject)
End If

If Parentobject IsNot Nothing Then
    Parentobject = VisualTreeHelper.GetParent(Parentobject)
End If

Dim myDesignerWindow = DirectCast(VisualTreeHelper.GetParent(Parentobject), System.Windows.Window)
If myDesignerWindow IsNot Nothing Then
    myDesignerWindow.Close()
End If
Lech Kulikowski
Posts: 7332
Joined: Tue Mar 20, 2018 5:34 am

Re: Closing Designer in Code in custom save window

Post by Lech Kulikowski »

Hello,

Thank you for sharing your experience with other users.
Post Reply