Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Diagram does not resize properly in an ElementHost control (Read 1999 times)
bogdip
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 70
Joined: Sep 8th, 2008
Diagram does not resize properly in an ElementHost control
Oct 16th, 2014 at 4:42pm
Print Post  
Hello,

I need to used the Wpf diagram inside a WinForms application. So I've added the Diagram inside an ElementHost control with Dock set to Fill. The problem is that when the main form is maximized, the Diagram is not taking all the space in its host container.

The issue occurs if Diagram.MeasureUnit is the default one (WpfPoint). If I set it to millimeter or inch, it's alright. But I need to use the WpfPoints.

I attach you a simple sample to reproduce it.
What can I do to overcome this?

Thanks,
Bogdan
  

WPFDiagramInsideWinForm.rar (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram does not resize properly in an ElementHost control
Reply #1 - Oct 17th, 2014 at 9:20am
Print Post  
Hi,

The diagram's size depends on its Bounds property. You could handle the SizeChanged event of your user control to grow Bounds if necessary:

Code
Select All
public DiagramControl()
{
    InitializeComponent();

    Diagram.DocumentPlane.AllowDrop = true;

    SizeChanged += DiagramControl_SizeChanged;
}

private void DiagramControl_SizeChanged(object sender, SizeChangedEventArgs e)
{
	var diagBounds = diagram.Bounds;
	if (diagBounds.Width < e.NewSize.Width)
		diagBounds.Width = e.NewSize.Width;
	if (diagBounds.Height < e.NewSize.Height)
		diagBounds.Height = e.NewSize.Height;
	diagram.Bounds = diagBounds;
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
bogdip
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 70
Joined: Sep 8th, 2008
Re: Diagram does not resize properly in an ElementHost control
Reply #2 - Oct 17th, 2014 at 9:43am
Print Post  
I was trying the same method, but setting the diagram's Width and Height properties instead of Bounds and it didn't work.

Thanks, now it works.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint