Click here to Skip to main content

Silverlight / WPF

 
QuestionBinding issues with Treeview C# WPF Pinmemberbartbartb2-May-13 12:41 
AnswerRe: Binding issues with Treeview C# WPF PinprofessionalKenneth Haugland3-May-13 3:22 
AnswerRe: Binding issues with Treeview C# WPF PinprofessionalMycroft Holmes9-May-13 13:23 
QuestionVisualTreeHelper.HitTest / RectangleGeometry not working... PinmemberSledgeHammer012-May-13 8:26 
Trying to use VisualTreeHelper.HitTest on a TreeView. I have two arbitrary items. TreeViewItem1 and TreeViewItem2. These items may appear anywhere on the tree and have any sort of relationship (different parents, etc.). I've gotten the top left point of the two items. pt1 and pt2. I want to find the visible TreeViewItems in between. So I did:
 
VisualTreeHelper.HitTest(ParentTreeView, new HitTestFilterCallback(A), new HitTestResultCallback(B), new GeometryHitTestParameters(new RectangleGeometry(new Rect(0, pt1.Y, ParentTreeView.ActualWidth, (pt2.Y + 1) - pt1.Y))));
 
HitTestFilterBehavior A(DependencyObject potentialHitTestTarget)
          {
               if (potentialHitTestTarget is TreeViewItemEx)
               {
                    if (((UIElement)potentialHitTestTarget).IsVisible)
                         System.Diagnostics.Debug.WriteLine(potentialHitTestTarget);
               }
 
               return HitTestFilterBehavior.Continue;
          }
 
          HitTestResultBehavior B(HitTestResult result)
          {
               return HitTestResultBehavior.Continue;
          }
 
This code is working for the most part, except it's also returning parent items that it shouldn't. If my tree looks like:
 
1
_2
__3
 
and the two items in question are 2 & 3, the hit-test also returns 1.
 
A more ugly example is:
 
Root
_NodeWithChildren1
_NodeWithChildren2
_NodeWithChildren3
__1
__2
__3
 
the tree looks exactly like that on the screen. The items in question are _NodeWithChildren3 and __1. The hit-test returns Root and _NodeWithChildren1 and _NodeWithChildren2 as well.
 
Any ideas? I have confirmed that I am getting the correct item1 & item2 that I think I am getting and I have confirmed that the points I am getting are correct as well.
AnswerRe: VisualTreeHelper.HitTest / RectangleGeometry not working... PinprofessionalKenneth Haugland2-May-13 8:38 
QuestionTab Closing Problem PinmemberKevin Marois1-May-13 21:14 
AnswerRe: Tab Closing Problem PinmemberAmitosh Swain3-May-13 5:49 
QuestionAsynchronous Call Using MVVM Pinmemberjonkjon29-Apr-13 11:21 
AnswerRe: Asynchronous Call Using MVVM PinmemberSledgeHammer0129-Apr-13 11:32 
GeneralRe: Asynchronous Call Using MVVM Pinmemberjonkjon29-Apr-13 11:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web01 | 2.8.150224.1 | Last Updated 22 Feb 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid