visualtreehelper

WPF Get Element(s) under mouse

Is there a way with WPF to get an array of elements under the mouse on a MouseMove event? ...

How to detect if a Surface Contact is over a ScatterView?

This is a (kind of) similar situation as in the SDK Sample Shopping Cart for MS Surface. I have an application with two ScatterViews. The first covers the complete Surface window ('surface'). The second resides in a TagVisualization object ('pod'). There might be more than one pod available (if more than one tag is down on the table). ...

Get the parent listview from a gridview object

Hi, In the code-behind of a WPF application I have a variable containing a GridView. I know for sure that this GridView is the View of a ListView. Is there any way to get a reference to that ListView? Thanks ...

How can you "plug into" the WPF rendercycle to get accurate results from VisualTreeHelper?

I am currently writing a WPF User control (PARENT) which can contain multiple child (CHILD) user controls. I am connecting the (CHILD) controls with polylines. To do this I need the locations of the CHILD user controls. However, the locations i get from VisualTreeHelper.GetOffset are zero. WPF is probably not finished yet with sizing an...

FindElementsInHostCoordinates Relative To Control Space Not Entire Page

I'm using the VisualTreeHelper method FindElementsInHostCoordinates to find a ListBoxItem at the given X and Y location. However, X and Y value appear to be related to points in the entire page not just the ListBox I'm interested in (even though I'm passing in that element into the subtree parameter of the method). Below, this refers t...

Finding the TextBlock that is part of the default control template ComboBox generated through code.

I'm trying to find the TextBlock that is inside the control template of a comboBox. using VisualTreeHelpar.GetChildrenCount is working only if the comboBox is declared in XAML.In that case GetChildrenCount returns 1 and a recursive search is possible. However, if I declare the combo as a member of the Window class using code, allocated...

SIlverlight: Can't find Image on Canvas

In my Canvas, I have an image object. I haven't set a source in it, but it has coordinates and a size. The tag is: <Image Canvas.Top="50" Canvas.Left="20" Height="68" Width="110" HorizontalAlignment="Left" Name="image1" Stretch="Fill" VerticalAlignment="Top" /> Here's the problem: When I move the mouse over it, I want to find it. With ...

How to calculate a bounding box for an Expander?

I have an Expander control and i need to calculate its bounds without invisible elements and margins. It commonly can be done by VisualTreeHelper.GetDescendantsBounds. But it seems that the rect is calculated by VisualTreeHelper doesn't depend on the expander state. For example: http://i.piccy.info/i5/58/39/273958/collapsed.jpg (i can'...

Problem with VisualTreeHelper.HitTest in WPF

I'm trying to hit-test a bunch of UserControls on a Canvas. I don't want the HitTest() to walk the whole way through the visual tree, so I'm using the FilterCallback to make sure I only hit-test the UserControl. My problem is that the UserControl never hits, it should, but it doesn't. If I use the FilterCallback, I return that it hit ...

Bounds rectangle of selected controls in wpf

Is there a simple way to find the rectangle (area and location) that would be required to cover a set of control?? VisualTreeHelper.GetDescandentBounds() works fine, but there are no overloaded methods where I can specify the controls that it should consider for finding the bounds rectangle. Any simple solution will be greatly appreciate...

Getting ListBox Items Silverlight

Hello All, I have tried to get the listbox items using VisualTreeHelper class. When I do VisualTreeHelper.GetChildrenCount((DependencyProperty)listBox1) it returns count as 0. But the listbox has lot of listboxitems in it.Can someone let me know if I am doing any mistake? Regards, Lalith ...

Finding a Visual beneath my own using WPF VisualTreeHelper advanced hit-testing

I have a seemingly simple task. Imagine a point, a visual tree and some Visual (point is within Visual). I want to use advanced hit-testing to get my hands on the first "leaf" Visual that is "behind" my own Visual. I have used VisualTreeHelper and its fancy hit-test methods but could not get the results I wanted. ...

How to access new visual tree when WPF TabControl SelectedItem changes

Considering an already loaded and rendered TabControl with three tabs, with selected tab being index 1 (the middle one): Tab 1: Has one TextBox Tab 2: Has two TextBoxes Tab 3: Has three TextBoxes If I iterate through the selectedItem's visual tree with VisualTreeHelper, I will get Two textBoxes within the TabControl's children. I wa...