This project is read-only.

CheckBox in a TreeView on a DockableContent is not checked.

Jul 30, 2011 at 3:43 AM

Clicking a CheckBox in a TreeView on a DockableContent which is not focused, does not check the CheckBox but just focuses the DockableContent. 

I have to click it again to check the CheckBox. I already set DefaultElement to the TreeView, but it didn't work. Setting the DefaultElement worked with Buttons, but not with TreeView. What am I missing?


Steps to reproduce.

1. Download latest Avalon source and run the AvalonDock.DemoApp35.

2. Replace the content of SampleDockableContent.xaml with

    <TreeView ItemsSource="{Binding Path=Data}">
            <HierarchicalDataTemplate DataType="TreeViewItem">

3. Add the following code and required usings to SampleDockableContent.xaml.cs.

		public List<String> Data
			get { return _Data; }
		List<string> _Data = new List<string>() { "hello""world" };

4. Run the demo program. When the document pane is focused, click the "hello" checkbox.

Expected Result: the "hello" should be checked

Actual Result: it's not checked but the panel is focused.

Aug 1, 2011 at 8:19 AM

Commented out the following lines in ManagedContent.cs (line 660), and now the checking works as expected.

I don't know if there would be any side effects of this...


                                else if (Content is UIElement && Content is DependencyObject)
                                    //Debug.WriteLine("Try to set kb focus to " + this.Content.ToString());
                                    //(Content as UIElement).Focus();
                                    //IInputElement kbFocused = Keyboard.Focus(this.Content as IInputElement);
                                    //if (kbFocused != null)
                                    //    Debug.WriteLine("Focused element " + kbFocused);
                                    //    Debug.WriteLine("No focused element");