private void InitializeComponent() { AvaloniaXamlLoader.Load(this); tree = this.FindControl <Avalonia.Controls.TreeView>("tree"); tree.DoubleTapped += ShowStateAfter_Click; tree.KeyDown += tree_KeyDown; // var items = tree.ContextMenu.Items.Cast<MenuItem>().ToList(); tree.FindControl <MenuItem>("ShowStateBefore").Click += ShowStateBefore_Click; tree.FindControl <MenuItem>("ShowStateAfter").Click += ShowStateAfter_Click; tree.FindControl <MenuItem>("DebugStep").Click += DebugStep_Click; }
private void InitializeComponent() { AvaloniaXamlLoader.Load(this); tree = this.FindControl <Avalonia.Controls.TreeView>("tree"); }
/// <inheritdoc/> protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnAttachedToLogicalTree(e); _treeView = this.GetLogicalAncestors().OfType<TreeView>().FirstOrDefault(); if (ItemTemplate == null && _treeView?.ItemTemplate != null) { ItemTemplate = _treeView.ItemTemplate; } }
public void TreeView_Is_Freed() { using (UnitTestApplication.Start(TestServices.StyledWindow)) { Func<Window> run = () => { var nodes = new[] { new Node { Children = new[] { new Node() }, } }; TreeView target; var window = new Window { Content = target = new TreeView { DataTemplates = new DataTemplates { new FuncTreeDataTemplate<Node>( x => new TextBlock { Text = x.Name }, x => x.Children) }, Items = nodes } }; // Do a layout and make sure that TreeViewItems get realized. LayoutManager.Instance.ExecuteInitialLayoutPass(window); Assert.Equal(1, target.ItemContainerGenerator.Containers.Count()); // Clear the content and ensure the TreeView is removed. window.Content = null; LayoutManager.Instance.ExecuteLayoutPass(); Assert.Null(window.Presenter.Child); return window; }; var result = run(); PurgeMoqReferences(); dotMemory.Check(memory => Assert.Equal(0, memory.GetObjects(where => where.Type.Is<TreeView>()).ObjectsCount)); } }
private void InitializeComponent() { AvaloniaXamlLoader.Load(this); _tree = this.FindControl<TreeView>("tree"); }