Questions tagged [visual-tree]
106 questions
4
votes
2 answers
How can a CanExecute of a commandBinding fire once the element has been removed from the visual tree?
I have a related question here where i have a user control with a command binding. The user control has being removed from the visual tree, yet the canExecute is still firing. My understanding of the Commanding model was that it bubbles and tunnels…

Aran Mulholland
- 23,555
- 29
- 141
- 228
4
votes
1 answer
Find control in the visual tree
I am trying to get my SelectedRadioButton from a DataTemplate.
Wpf Inspector showed the Visual Tree:
and in code:
void menu_StatusGeneratorChanged(object sender, EventArgs e)
{
var status =…

Gerard
- 13,023
- 14
- 72
- 125
4
votes
2 answers
Why AdornerLayers are always the top most layers? Is there a way to change it?
Why is that the adorner layer is always rendered as the top most layer in an application (under AdornerDecorator - refer screenshot)?
Is there a way to change the layer/level on to which the adorners can be drawn?
In the following screenshot,…

sudarsanyes
- 3,156
- 8
- 42
- 52
4
votes
2 answers
Why does binding fail when binding a child element to another element when the parent succeeds?
Say I have two classes that can reference a third UI object (in this example a button).
In addition, the parent class can contain an element of the child class.
If they both are bound to the same control, the same way, the child will fail but the…

Jeremy White
- 901
- 2
- 9
- 21
4
votes
3 answers
Is walking the visual tree bad practice?
Lately I've seen some comments about walking the visual tree being bad practice (here for instance), but I haven't seen or found a reason for why this would be bad practice.
In a project I'm working on there's quite a bit of tree walking, so I'm…

Eirik
- 4,135
- 27
- 29
3
votes
2 answers
How to get the Window hosting a UIElement instance
I'm trying to get the Window instance which is hosting a UIElement instance in WinUI 3.
There's a helper method in the Window class in .NET (see this thread) but i cannot find something similar for C++/WinRT.
I tried VisualTreeHelper as some…

ridilculous
- 624
- 3
- 16
3
votes
3 answers
Cannot see XAML live visual tree
Before reporting to Microsoft I want to ask here. I have a problem that I cannot see Live Visual Tree of my WinUI 3 application. I cannot even see the in-app toolbar. I can see both in WPF and UWP application, no problems. I have these options for…

benderto
- 896
- 11
- 39
3
votes
1 answer
How to find the Parent of a CustomControl from inside the CustomControl
I have a class which extends Canvas in WPF.
This class is placed in a ScrollViewer.
Without passing a specific reference to the ScrollViewer into the Canvas, I want to find the ScrollViewer which contains the Canvas from within the Canvas…

Alex
- 1,643
- 1
- 14
- 32
3
votes
2 answers
WPF: How to walk up the Visual Tree to find a Model3DGroup a clicked 3d-model is in?
I'm displaying a few 3D-models as Model3DGroups.
They are surrounded by Viewport3D which catches MouseDown-events.
I want to determine which Model3DGroup (they all have names) was clicked.
I'm starting with this:
Point location =…

Hedge
- 16,142
- 42
- 141
- 246
3
votes
1 answer
What are the font properties in WPF that are inherited through the visual tree?
WPF has certain font properties that are inherited through the visual tree. This for instance allows changing of the FontFamily on a UserControl and have all the text in it reflect that change.
What are all the font-related properties that are…

NextInLine
- 2,126
- 14
- 23
3
votes
1 answer
WPF find element with VisualTreeHelper vertical and horizontal
What is the easiest way, to search vertically and horizontally in the visual tree?
For example I want to find a control which is not in the list of parents from the control, which starts the search.
Here is a simple example (every box represents…

BendEg
- 20,098
- 17
- 57
- 131
3
votes
2 answers
How to debug the visual tree if an "Must disconnect specified child from current parent Visual before attaching to new parent Visual" exception occurs
How do you debug the following Error?
Must disconnect specified child from current parent Visual before attaching to new parent Visual.
I'm sure i understood the meaning of this Exception but in case I have missed something important here is what…

WiiMaxx
- 5,322
- 8
- 51
- 89
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
3
votes
1 answer
Caliburn.Micro message bubbling skipping a control
I've got a hierarchical collection and I lazy load the lowest level because of it's size.
The action I'm trying to activate is on the CollectionHolderManager but it seems that the bubbling skips that visual layer for some reason.

Ingó Vals
- 4,788
- 14
- 65
- 113
3
votes
1 answer
"FindName" doesn't work if an element added in code
In a WPF app, if a ContentControl is declared in XAML,
then I can easily reference it in code using FindName:
ContentControl cc = FindName("MyContentControl") as…

rem
- 16,745
- 37
- 112
- 180