views:

381

answers:

1

Not sure there's too many surface developers on here but hey ho...

If i have a scatterview which implicity creates the ScatterViewItem objects (see below), is it possible to retireve the contact events for each scatterViewItem? Also when i wrap tyhe image object in a ScatterViewItem explicitly the item no longer works. Could anyone advise as to why this is the case?

<s:ScatterView ItemsSource="{StaticResource DummyData}" >
   <s:ScatterView.ItemTemplate>
      <DataTemplate>
         <Image Source="{Binding Path=ImagePath}" />
      </DataTemplate>
   </s:ScatterView.ItemTemplate>
 </s:ScatterView>
+2  A: 

Wrapping the image in a scatterviewitem inside the datatemplate won't help because the scatterview will still generate and wrap it with another scatterviewitem as long as you're using ItemsSource. The only way to prevent that would be to explicity create and add svi's to the items collection on the scatterview in code behind, but that would give up the data binding advantages.

To get to your original question, I'm assuming you want to know when a ContactDown or ContactUp event happens on any generated scatterviewitem right? Since these are routed events, you can just subscribe at the scatterview level.

  <s:ScatterView ItemsSource="{StaticResource DummyData}" 
                 s:ScatterViewItem.ContactDown="OnSVIContactDown">
    <s:ScatterView.ItemTemplate>      
        <DataTemplate>         
           <Image Source="{Binding Path=ImagePath}" />      
        </DataTemplate>   
    </s:ScatterView.ItemTemplate> 
  </s:ScatterView>
Ben Reierson
Of course. Cheers dude.
James Hay
+1 for the question and the code sample
gyurisc