<Grid>
<DockPanel>
<syncfusion:SfDiagram x:Name="myDiagram" Background="Gray"/>
</DockPanel>
</Grid> |
Hi Utemar,Thanks for contacting Syncfusion support.Requirement: Fit SfDiagram into xaml page.We have prepared the sample based on the provided code example. We were unable to face any issues from our end and SfDiagram has fully fit into the xaml page. Please refer the code example and video link as below.Code example: We set the background color for SfDiagram to represent the requirement.
<Grid><DockPanel><syncfusion:SfDiagram x:Name="myDiagram" Background="Gray"/></DockPanel></Grid>Regards,Ramya T
Hi Utemar,Thanks for your update.We were unable to understand the requirement from the given query. Could you please provide us the screenshot or video to represent your requirement? This will help us to provide you the appropriate solution at the earliest.Regards,Ramya T
Hi Utemar,Thanks for your update.We were unable to understand the requirement from the given query. Could you please provide us the screenshot or video to represent your requirement? This will help us to provide you the appropriate solution at the earliest.Regards,Ramya T
private void MainWindow_ViewPortChangedEvent(object sender, ChangeEventArgs<object, ScrollChanged> args)
{
if(args.NewValue.ContentBounds!=Rect.Empty)
{
(Diagram.Info as IGraphInfo).BringIntoCenter(args.NewValue.ContentBounds);
}
} |
Hi Utemar,Thanks for sharing sample and screenshot to represent the requirement.Diagram supports manual and automatic arrangement of node in Diagram. In manual positioning depends on OffsetX and OffsetY property of nodes. For your scenario(manual), we can achieve your requirement by using ViewPortChangedEvent and BringIntoCenter method. Please find the code example and modified sample as below.ViewPortChangedEvent: It will be invoked whenever the size of the diagram or page get modified(Zooming, Dragging etc.…).BringIntoCenter : It will bring the specific region or bounds into center of the diagram.Sample Link:
FlowDiagram_XAML
Code example:
private void MainWindow_ViewPortChangedEvent(object sender, ChangeEventArgs<object, ScrollChanged> args){if(args.NewValue.ContentBounds!=Rect.Empty){(Diagram.Info as IGraphInfo).BringIntoCenter(args.NewValue.ContentBounds);}}Regards,Ramya T
Hi Utemar,Thanks for your update.Could you please confirm us whether page setting is used in your application, share us the simple video to represent the issue and code example of Sfdiagram definition in your application?This will help us to investigate further on the reported issue and provide you the appropriate solution at the earliest.Regards,Ramya T
private void MainWindow_ViewPortChangedEvent(object sender, ChangeEventArgs<object, ScrollChanged> args)
{
// This condition is used to check whether the bounds is not empty and the old bounds and new bounds are not equals to each other.
if (args.NewValue.ContentBounds != Rect.Empty && args.OldValue.ContentBounds != args.NewValue.ContentBounds)
{
(Diagram.Info as IGraphInfo).BringIntoCenter(args.NewValue.ContentBounds);
}
} |
Hi Utemar,Reported Issue : Could not able to scroll the diagram vertically.We have analyzed the provided sample and able to reproduce the reported issue. We have provided modified code example and sample for this. Please find the code example and sample link below.Code Example:
private void MainWindow_ViewPortChangedEvent(object sender, ChangeEventArgs<object, ScrollChanged> args){// This condition is used to check whether the bounds is not empty and the old bounds and new bounds are not equals to each other.if (args.NewValue.ContentBounds != Rect.Empty && args.OldValue.ContentBounds != args.NewValue.ContentBounds){(Diagram.Info as IGraphInfo).BringIntoCenter(args.NewValue.ContentBounds);}}Sample link : https://www.syncfusion.com/downloads/support/forum/145445/ze/FlowDiagram_XAML523627678Regards,Ramya T
private void MainWindow_ViewPortChangedEvent(object sender, ChangeEventArgs<object, ScrollChanged> args)
{
var Item = args.Item as SfDiagram;
var horizontaloffset = Item.ScrollSettings.ScrollInfo.HorizontalOffset;
var dummyRect = new Rect(0,0,0,0);
if ((args.OldValue.ContentBounds == dummyRect && args.NewValue.ContentBounds != dummyRect) ||
(args.NewValue.ContentBounds != Rect.Empty &&
Math.Round(Math.Abs(horizontaloffset), 0) != Math.Round(Item.ScrollSettings.ScrollInfo.ViewportWidth / 2, 0)))
{
(Diagram.Info as IGraphInfo).BringIntoCenter(args.NewValue.ContentBounds);
}
} |
Hi Utemar,Requirement: Content always at the center of the viewportWe have analyzed your requirement and modified the provided sample. In the sample, we have checked conditions in ViewPortChanged event to achieve your requirement. We have provided code example and modified sample for this. Please find the modified sample and code example below.Code Example:
private void MainWindow_ViewPortChangedEvent(object sender, ChangeEventArgs<object, ScrollChanged> args){var Item = args.Item as SfDiagram;var horizontaloffset = Item.ScrollSettings.ScrollInfo.HorizontalOffset;var dummyRect = new Rect(0,0,0,0);if ((args.OldValue.ContentBounds == dummyRect && args.NewValue.ContentBounds != dummyRect) ||(args.NewValue.ContentBounds != Rect.Empty &&Math.Round(Math.Abs(horizontaloffset), 0) != Math.Round(Item.ScrollSettings.ScrollInfo.ViewportWidth / 2, 0))){(Diagram.Info as IGraphInfo).BringIntoCenter(args.NewValue.ContentBounds);}}Sample Link : https://www.syncfusion.com/downloads/support/forum/145445/ze/FlowDiagram_XAML-606297707Regards,Ramya T