Questions tagged [visualtreehelper]

92 questions
3
votes
1 answer

Get the parent listview from a gridview object

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
J W
  • 1,679
  • 4
  • 20
  • 28
3
votes
2 answers

Why VisualTreeHelper.GetChildrenCount() returns 0 for Popup?

I move focus to the Popup on its opening: wcl:FocusHelper.IsFocused="{Binding RelativeSource={RelativeSource Self}, Path=IsOpen}" FocusHelper class code: public static class FocusHelper { public static readonly DependencyProperty…
Pavel Voronin
  • 13,503
  • 7
  • 71
  • 137
2
votes
2 answers

ItemsControl has no children during MainWindow's constructor

Based on the answer to SO question "WPF: arranging collection items in a grid", I have the following:
Avi
  • 15,696
  • 9
  • 39
  • 54
2
votes
1 answer

VisualTreeHelper.HitTest reports a hit even when rectangle is nowhere near the underlying shapes

I am attempting to implement Rubber-band selection of WPF Path objects on a canvas. Unfortunately my use of VisualTreeHelper.HitTest with a rectangle geometry is not working as I expect. I expect to only get a hit when some part of my…
Joe
  • 5,394
  • 3
  • 23
  • 54
2
votes
3 answers

How to detach from the Visual Tree in WPF

I'm trying to correctly remove a UIElement from an InlineUIContainer in order to use it in another Panel but the program keeps crashing with this message "Specified Visual is already a child of another Visual or the root of a CompositionTarget.".…
Prince Owen
  • 1,225
  • 12
  • 20
2
votes
0 answers

Find child element from ListBox wp8

I am trying to find child element from Listbox. Listbox contains Itemtemplate. Here is my design. I have created UserControl. In that I have added ListBox. I am showing this control as pop up. Here is code for pop up GlobalSettings.popup =…
Ajay
  • 6,418
  • 18
  • 79
  • 130
2
votes
1 answer

try to get in code behind button, which is nested in data template

I have db which filling my listbox and before next step, I want to have a chance to customize choice of user with tooglebuttons. So I want to get the info about his choices in codebehind. I find in this answer the code which uses…
MyWay
  • 1,011
  • 2
  • 14
  • 35
2
votes
3 answers

How to add an option to selectively remove items from ComboBox?

I have a ComboBox that displays strings. How can I add an option to remove some items from the ComboBox list? I tried:
Tar
  • 8,529
  • 9
  • 56
  • 127
2
votes
2 answers

Getting the index of the selected RadioButton in a group

I have got a reference to a RadioButton rb1. How can I get the index of the selected RadioButton in rb1's group ? I have googled for a while but without success. Any help will be greatly appreciated
user1139666
  • 1,687
  • 4
  • 24
  • 45
2
votes
1 answer

LogicalTreeHelper.GetChildren - ObservableCollection Move() causing ContentControl in DataTemplate to lose it's content?

This is very strange. The point of the code below is to support an attachedProperty which will notify a container if any of it's children have received focus. i.e. I have a Grid with a textBox somewhere in it's Content and I want to turn the Grid…
tronious
  • 1,547
  • 2
  • 28
  • 45
1
vote
1 answer

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').…
Bart Roozendaal
  • 815
  • 2
  • 9
  • 21
1
vote
1 answer

Problems with VisualTreeHelper Hit test in landscape

I'm using the FindElementsInHostCoordinates method to find elements as the user swipes his finger across the screen. I'm noticing that it is reacting to if the phone was in portrait. For example - As I move my finger up it moves down, and as I move…
Tom
  • 1,187
  • 2
  • 12
  • 21
1
vote
1 answer

Find control's ancestor by type

I have a UserControl 'child' within another UserControl (that's acting as a TabItem in a TabControl). Between the child UserControl and the TabItem ancestor are a number of other controls (eg: Grids, a StackPanel, possibly a ScrollViewer, etc). I…
mcalex
  • 6,628
  • 5
  • 50
  • 80
1
vote
1 answer

HitTest and RayMeshGeometry3DHitTestResult programmatically in a window-less console application

I need to perform the intersection of a line and a triangle mesh. That operation would be very conveniently performed if I could use VistualTreeHelper.HitTest method, that would return a RayMeshGeometry3DHitTestResult structure. The problem is:…
heltonbiker
  • 26,657
  • 28
  • 137
  • 252
1
vote
1 answer

How Can I Access to The Controls in DataTemplate in ListBox in WPF

I have a ListBox including an ItemTemplate with a StackPanel. I want to access that stackpanel and change its visibility. (Change it's visibility to collapsed when I click mouseleftbutton "closeAll") I can do that with FindDescendantByName Method…
Barsblue
  • 109
  • 1
  • 15