Diagram in a Viewbox


I’m having some trouble with selecting nodes when the diagram is contained within a Silverlight ViewBox.

The repro below is a contrived example of an application which wraps most of its visual tree in a ViewBox to more accurately perform zooming within the application – similar to how modern browsers can zoom their content.

The issue seems to be that the diagram coordinate system goes awry when translating model coordinates in to physical coordinates before performing a VisualTreeHelper.FindElementsInHostCoordinates(...) operation.

With some investigation I found thatClickSelectingTool.FindPartAt(Point, bool) returns null when the mouse is directly over the node. Further, it returns the node when a mouse click occurs beyond the top-left of the node. I can’t really Debug this problem beyond this point without the source code to step through. Has anyone encountered this issue before?


<br />... <br /><UserControl.Resources> <br /> <DataTemplate x:Key="NodeTemplate"> <br /> <go:NodePanel Sizing="Fixed" Width="200" Height="200" go:Part.SelectionAdorned="True"> <br /> <Path go:NodePanel.Figure="Ellipse" Fill="Red" /> <br /> </go:NodePanel> <br /> </DataTemplate> <br /></UserControl.Resources> <br /> <br /><Grid Width="500" Height="500"> <br /> <Viewbox> <br /> <Grid Width="800" Height="800"> <br /> <go:Diagram x:Name="myDiagram" Padding="10" <br /> HorizontalContentAlignment="Center" VerticalContentAlignment="Center" <br /> NodeTemplate="{StaticResource NodeTemplate}"> <br /> <go:Diagram.Layout> <br /> <golayout:ForceDirectedLayout ConditionFlags="Standard GroupSizeChanged" /> <br /> </go:Diagram.Layout> <br /> </go:Diagram> <br /> </Grid> <br /> </Viewbox> <br /> </Grid> <br />... <br />

Thanks for mentioning the platform you are using, but exactly what four-part version of the GoSilverlight DLL are you using? Is it the latest 1.1.9 or 1.2.2, or is it a version older than 1.1.9?

1.1.9 and later have a bug fix similar to what you are encountering, although I don’t know if it applies to putting the Diagram within a Viewbox.

I just tried wrapping a Diagram in what you were using:

<Grid Width="500" Height="500" Grid.Row="3"> <Viewbox> <Grid Width="800" Height="800"> . . .
and it worked fine. This was with version 1.2 on Silverlight 4.

That included testing drag-and-drop from a Palette.

Ah! I was assuming I was up to date. I’ve updated to v1.2 and the problem has been fixed.