visual-tree


Move UIElement in Visual Tree without recalculating layout

↘锁芯ラ 提交于 2020-01-13 05:50:12
问题 We have a WPF application (.Net 4.0) using a Docking Control (Actipro). We can dock out the docking windows. In that case, a "real" Window is created and the content is assigned to that window. Of course, moving stuff in the Visual Tree will re-trigger the complete layouting . This is problematic, because in one of these docking windows, we have a diagramming control (Mindfusion Diagramming,WPF control) that can take up to 10 seconds to completely layout itself (very large diagrams). I don't

Concepts of Visual tree and Logical tree [closed]

早过忘川 提交于 2020-01-11 09:09:12
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 6 months ago . I understand the concepts of Visual and logical tree but still I am not able to understand the real use and need of these. Although its not necessary to know everything about these trees but I believe it will benefit in some advanced scenarios. I have already gone through

Where is ComboBox popup in visual tree?

狂风中的少年 提交于 2020-01-06 10:54:24
问题 Where in the visual tree can I find the ComboBox popup (the list with the ComboBoxItems)? I have programmatically opened a ComboBox and when watching it in the WPF Tree Visualizer in the debugger I see the following: : ComboBox templateRoot : Grid PART_Popup : Popup toggleButton : ToggleButton templateRoot : Border splitBorder : Border Arrow : Path contentPresenter : ContentPresenter : TextBlock I expected to see a ScrollViewer with some kind of item host (StackPanel?), perhaps where the PART

How to move a WPF UIElement from the visual tree to a FixedPage?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-05 06:31:06
问题 My MVVM application is using on-screen visual objects to render screen content to a printed document. My View has a ContentControl that uses DataTemplate resources to determine what to display, but when I try to add that content to a FixedPage object, I get an ArgumentException with the message: Specified Visual is already a child of another Visual or the root of a CompositionTarget. The (simplified) XAML code for the view that handles the printing looks like this: <DockPanel> <!-- Print

Is walking the visual tree bad practice?

雨燕双飞 提交于 2020-01-03 17:17:51
问题 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 wondering if I should bother changing all this to something else or just let it be as it is. So, I guess my main question here is if visual tree walking really is bad practice, and more importantly, if it is, why ? Also, where (if at all?) would it be

Find control in the visual tree

[亡魂溺海] 提交于 2019-12-29 00:39:25
问题 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 = Menu.Items.ItemContainerGenerator.Status; if (status == System.Windows.Controls.Primitives.GeneratorStatus.ContainersGenerated) { var item = Menu.Items.ItemContainerGenerator.ContainerFromIndex(0); // item is a ContentPresenter var control = Tools.FindChild<SelectedRadioButton>(item); control = Tools

Silverlight & Visual Tree Manipulation

不羁的心 提交于 2019-12-23 13:34:08
问题 Now this may be more trouble than it's worth but nevertheless, it'd be really useful to me right now. What I'd like to know is how I might go about manipulating the Silverlight visual tree at runtime. Doing simple things like adding and removing controls is easy enough but when you start having to traverse the tree with any reasonable amount of complexity I find myself yearning for a JQuery style syntax (LINQ would be pretty cool too I suppose) to handle DOM node replacements, movements and

Why does binding fail when binding a child element to another element when the parent succeeds?

久未见 提交于 2019-12-22 19:24:55
问题 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 parent succeed. Is this a bug in WPF? The parent : class MyFrameworkElement : FrameworkElement { // A depenedency property that will contain a child element sub-element private static readonly DependencyProperty ChildElementProperty =

WPF: In an attached property, how to wait until visual tree loaded properly?

非 Y 不嫁゛ 提交于 2019-12-22 09:26:04
问题 I have an Attached Property in a WPF app. The code below is inside the OnLoad event, but it doesn't work unless I add a hacky 500 millisecond delay in. Is there some way to avoid this delay, and detect when the visual tree has been loaded? private static void FrameworkElement_Loaded(object sender, RoutedEventArgs e) { // ... snip... Window window = GetParentWindow(dependencyObject); // Without this delay, changing properties does nothing. Task task = Task.Run( async () => { { // Without this

Move a UserControl from a ContentControl to another one programmatically

你离开我真会死。 提交于 2019-12-21 01:17:20
问题 In a WPF app I want to move a UserControl from a ContentControl to another one in code: myContentControl2.Content = myUserControl; in this case I get an error: Specified element is already the logical child of another element. Disconnect it first. In a ControlControl class description I can see a RemoveVisualChild method, but when I try to use it in code I get an Unknown method error myContentControl1.RemoveVisualChild(myUserControl);//here I get an "Unknown method" error Where am I wrong?

工具导航Map