Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Diagram create image shows window (Read 871 times)
Patryk
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 23
Joined: Jun 13th, 2025
Diagram create image shows window
Nov 14th, 2025 at 9:38am
Print Post  
Hello,

In our solution we are using the Diagram.CreateImage method.
Could you please introduce some additional parameter that will be considered by the CreateImage method so we will not get the little bar shown during using our tool?

If its a must to use the show window could you please advice how to avoid showing this bar?
  

code.png ( 304 KB | 32 Downloads )
code.png
bar.png ( 56 KB | 38 Downloads )
bar.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Online


tech.support

Posts: 3473
Joined: Oct 19th, 2005
Re: Diagram create image shows window
Reply #1 - Nov 14th, 2025 at 12:38pm
Print Post  
Hi,

The diagram presenter used to generate bitmap is attached to a window indeed, otherwise we couldn't get reliable output. The window is supposed to stay invisible, but maybe there's some open / close animation involved in newer versions of Windows or dotnet. We'll try also applying flags to hide window's titlebar.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Online


tech.support

Posts: 3473
Joined: Oct 19th, 2005
Re: Diagram create image shows window
Reply #2 - Nov 17th, 2025 at 10:48am
Print Post  
Hi,

Try this build, the window should stay hidden now -
https://www.nuget.org/packages/MindFusion.Diagramming.Wpf/4.2.2-beta1

Regards,
Slavcho
MindFusion
  
Back to top
 
IP Logged
 
Patryk
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 23
Joined: Jun 13th, 2025
Re: Diagram create image shows window
Reply #3 - Nov 19th, 2025 at 12:00pm
Print Post  
Thanks for sharing the build.
We will try to test once we will be able to.
I am more than glad if its works now
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Online


tech.support

Posts: 3473
Joined: Oct 19th, 2005
Re: Diagram create image shows window
Reply #4 - Mar 26th, 2026 at 10:27am
Print Post  
This build eliminates the hidden window altogether -

https://www.nuget.org/packages/MindFusion.Diagramming.Wpf/4.3.0-beta3

We think the window was needed for some scenario with v3's standalone Diagram control. Now CreateImage creates VisualBrush on top of DiagramPresenter and that seems to work without adding to the visual tree.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Patryk
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 23
Joined: Jun 13th, 2025
Re: Diagram create image shows window
Reply #5 - Apr 13th, 2026 at 6:40am
Print Post  
Hi Slavcho,

Yes it works thanks.

Though I'd still have another question - once the image is created by using the Diagram.CreateImage() we are loosing the internal visual part of our nodes - we kindly informing the user that the diagram will be closed after the export is done - this helps to walkaround the issue.

What also helps is that you can just slightly move the node (I assume some redraws methods are called underneath) and it also works.

Question - is there a way to redraw nodes from diagram level or to somehow force it to be refreshed?

Thanks in advance
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Online


tech.support

Posts: 3473
Joined: Oct 19th, 2005
Re: Diagram create image shows window
Reply #6 - Apr 13th, 2026 at 7:14am
Print Post  
Hi Patryk,

Do you mean that started happening with v4.3, or you had same behavior with 4.2 version?

It sounds like "losing internal visual part" happens in main diagram view? By that are you referring to losing Text / data bound values, or whole custom template of yours disappear?

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Patryk
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 23
Joined: Jun 13th, 2025
Re: Diagram create image shows window
Reply #7 - Apr 13th, 2026 at 7:26am
Print Post  
We used to have the same behavior earlier Wink We just had a walkaround so I didnt asked for it. But now once a new version appeared + you did some good improvments I would really like to get rid of our dialog that asks user if they want to close the diagram in order to export.

Yes, we are losing the whole custom template. As I said - its enough to even move the node by 1px and it shows once again. So I am assuming its somehow related to redrawing.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Online


tech.support

Posts: 3473
Joined: Oct 19th, 2005
Re: Diagram create image shows window
Reply #8 - Apr 13th, 2026 at 7:43am
Print Post  
Hi Patryk,

Our developer will try to reproduce that. Could you give us details on your configuration, such as are there any custom nodes, data triggers, CreateRenderer / DrawLocal overrides, CustomDraw events involved?

If moving a node repaints it correctly, you could try calling DiagramView.UpdateLayout after CreateImage to force repaint, possibly preceded by InvalidateMeasure.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Patryk
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 23
Joined: Jun 13th, 2025
Re: Diagram create image shows window
Reply #9 - Apr 13th, 2026 at 8:31am
Print Post  
FYI the updateLayout preceded by InvalidateMeasure does not resolve the issue.

Our CustomNodeView class inherits from your ControlNode. We do override the
Code
Select All
      protected override FrameworkElement CreateRenderer(bool activeView, bool lightweight)
 



It assign appropriate templates and returns the created presenter:

Code
Select All
         var presenter = new ContentPresenter
         {
            Content = nodeViewDataTemplate.LoadContent(),
         };

         ((FrameworkElement)presenter.Content).DataContext = DataContext;
         Control = presenter; 


  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Online


tech.support

Posts: 3473
Joined: Oct 19th, 2005
Re: Diagram create image shows window
Reply #10 - Apr 13th, 2026 at 9:13am
Print Post  
Does that override return cached Control when it's already set? Sharing same instance between different DiagramPresenters might not work (DiagramView and CreateImage ones). Check if these help as work-around:

- flag around CreateImage calls and always return new instance when the flag is set;
- reset DiagramView.Diagram after CreateImage;
- replace the DiagramView in main UI with new instance after CreateImage;

ControlNode itself does not fit very well in our v4 model/view separation, nor in WPF overall presentation logic. We keep it mostly to facilitate porting from our WinForms version, where corresponding type allows hosting UserControls as nodes. In WPF version, the hosted Control instance is moved around when a different DiagramView is activated, and it's probably left in the visual tree of CreateImage's temporary DiagramPresenter. We'll try to fix that by resetting Control parent when disposing CreateImage' visual tree.

In the long term, better consider changing the base type from ControlNode to TemplatedNode, and you might want to avoid caching node presenters even then (e.g. same problem could happen when node presenter is shared by DiagramView / Overview / export-related DiagramPresenters, as WPF does not allow sharing elements between different visual trees).

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Patryk
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 23
Joined: Jun 13th, 2025
Re: Diagram create image shows window
Reply #11 - Apr 15th, 2026 at 8:05am
Print Post  
Well, if the sharing would be an issue I think we would not get our images with appropriates nodes on it.

Code
Select All
         var presenter = new ContentPresenter
         {
            Content = nodeViewDataTemplate.LoadContent(),
         };

         ((FrameworkElement)presenter.Content).DataContext = DataContext;
         Control = presenter;
 



here the control gets a new presenter..and its also new presenter that is returned from the CreateRenderer method Smiley

I could try to implement your work-arounds but I dont really now what you mean by "always return new instance when the flag is set"

Also reset the diagramView - does the API expose some resets methods?

  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Online


tech.support

Posts: 3473
Joined: Oct 19th, 2005
Re: Diagram create image shows window
Reply #12 - Apr 15th, 2026 at 8:29am
Print Post  
Quote:
I think we would not get our images with appropriates nodes on it.


The way DiagramPresenter handles ControlNodes, moving Control from inactive to active presenters, I think you are seeing them in exported image because Control's UIElement is effectively moved from the view to the image (the temporary DiagramPresenter used to render it), but not back to the view Smiley If you were using TemplatedNode as a base, it should just call CreatePresenter to get a new UIElement.

By replacing DiagramView, I mean remove current instance from parent panel's Children, and add an all-new DiagramView displaying same Diagram. That should hopefully force new CreateRenderer calls.

Anyways, our developer will try to fix ControlNode export in next few days.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Online


tech.support

Posts: 3473
Joined: Oct 19th, 2005
Re: Diagram create image shows window
Reply #13 - Apr 16th, 2026 at 7:23am
Print Post  
Another work-around you could try is exporting image of a cloned diagram, but make sure your ControlNode.Clone override isn't reusing the Control instance:

Code
Select All
var image = diagram.Clone().CreateImage(); 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Patryk
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 23
Joined: Jun 13th, 2025
Re: Diagram create image shows window
Reply #14 - Apr 16th, 2026 at 10:28am
Print Post  
Thanks for sharing and thinking about my issue Smiley

I think I've tried already to clone it - some exception was thrown during this operation. In free time I will re-check.

Though if your team will provide the fix for controlNode I think I can wait
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint