Note that there are some explanatory texts on larger screens.

plurals
  1. POFinding Child Objects in ViewBox/Canvas Object
    primarykey
    data
    text
    <p>I've implemented a drag and drop that is mostly working in my Silverlight 4 app. Once the users have dropped the shapes onto the canvas, I wanted to use <a href="http://www.silverlight.net/community/samples/silverlight-samples/size-rotation-decorators/" rel="nofollow">Size &amp; Child Decorators</a>. I've tried to implement the sample code. Code below is problem section of much larger app.</p> <p>xmal -</p> <pre><code>&lt;ScrollViewer Grid.RowSpan="1" Grid.Row="2" Grid.ColumnSpan="2" Grid.Column="2" Name="scrollViewer"&gt; &lt;Viewbox Margin="0" MinWidth="400" MinHeight="500" HorizontalAlignment="Left" VerticalAlignment="Top" Name="ViewBoxTestBuild"&gt; &lt;Canvas x:Name="Camera1Canvas" telerikDragDrop:RadDragAndDropManager.AllowDrop="True" Width="1200" Height="768" MouseLeftButtonDown="Camera1Canvas_MouseLeftButtonDown"&gt; &lt;Image x:Name="Camera1Image" Source="timemagadj.jpg" Canvas.ZIndex="-1" HorizontalAlignment="Left" VerticalAlignment="Top" /&gt; &lt;local:Three_Line_Graphic x:Name="threeLineEditTool" HorizontalAlignment="Left" Canvas.Left="594" Canvas.Top="621" /&gt; &lt;l:Adorner x:Name="adorn" Canvas.ZIndex="100" /&gt; &lt;/Canvas&gt; &lt;/Viewbox&gt; &lt;/ScrollViewer&gt; </code></pre> <p>c# code -</p> <pre><code>private void Camera1Canvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { var sendingObj = sender as Canvas; if (sendingObj == null) return; foreach (UserControl l in VisualTreeHelper.FindElementsInHostCoordinates(e.GetPosition(null), sendingObj)) { if (l.Parent == Camera1Canvas ) { adorn.AdornedElement = l as FrameworkElement; adorn.adorned_MouseLeftButtonDown(l, e); break; } } base.OnMouseLeftButtonDown(e); } </code></pre> <p>My problem is that when VisualTreeHelper.FindElementsInHostCoordinates is called on left mouse click event, it returns no elements when I click on any object. I sure that it is a coordinate mapping issue, but as this is new ground for me, I'm unsure how to fix it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload