For my WPF TreeView user control, I would like to display a progress ring around a ToggleButton to indicate that the node's children are populating, like so:
(Full disclosure, I saw this type of behavior in some open source software, I just can't remember where). I still want the toggle button to be interactive (i.e., get mouse events, like hover and click) so the user can collapse the node if they no longer wish to wait for the update to complete.
My first thought was to add the progress ring as an adorner layer to the ToggleButton. However, since the WPF adorner layer lies on top of the UI element in Z-order, I cannot seem to interact with the toggle button below the progress ring. Is there a way to draw the toggle button on top of the adorner layer? Or does an adorner layer not seem like the right approach in this case? Would it be better to just trigger off a property to control the template of the toggle button and draw both the progress ring and the toggle button when updating the children? Thanks for any thoughts!
Relevant tutorials I am leveraging off:
Working with Checkboxes in the WPF TreeView
WPF Loading Wait Adorner (which has links to progress ring and adorner sources)
I believe you don't need adorners to acomplish what you desire. I've edited tree view template via Blend, adding user control with busy animation to expander button in treeview item style. There is a lot to be done, but it can demonstrate you the approach. Also there is probably a better way to change visibility of indicator, rather then searching for it in a visual tree.
The way I see it is to create custom controls for treeview and treeviewitem. Override it's style and add a "IsLoading" property for treeviewitem. Switching this property should change visibility of usercontrol.
MainWindow.xaml
MainWindow.cs
UserControl1.xaml