Requirements
R1. When the user clicks on a node the LOD (load on demand) occurs and when complete expands its children.
R2. When the user clicks the expansion icon LOD occurs and when completes expands the its children.
Both R1 and R2 should ultimately result in the same feedback to the user.
As of now
R1. Success -This works fine. When the user selects a node in the tree I bubble this up to the viewmodel (PRISM) and your Load On Demand infrustrucure kicks in by presenting the loading icon and once the children have been populated expands the node and removes the loading icon.
R2. Fail
What occurs is that when the user clicks the expansion icon, LoadOnDemand is fired but we don't get the loading icon and when the results come back the node doesn't expand even though the children have been populated. In the end the users feels like they can single click a node but dubble click the expansion icon.
Code in my View
| /// <summary> |
| /// Handles the selection changed event |
| /// </summary> |
| /// <param name="sender">The sender</param> |
| /// <param name="e">The event args</param> |
| private void RadTreeView_Selected(object sender, RadRoutedEventArgs e) |
| { |
| var item = e.Source as RadTreeViewItem; |
| if (item == null) return; |
| if (item.IsExpanded) return; // Don't load on collapse |
| var model = item.Item as HierarchicalModelBase; |
| if (model == null) return; |
| // Bubble |
| if (ModelSelected != null) |
| ModelSelected(this, new HierarchicalModelSelectedEventArgs {Model = model}); |
| } |
| /// <summary> |
| /// Handles the load on demand event |
| /// </summary> |
| /// <param name="sender">The sender</param> |
| /// <param name="e">The event args</param> |
| private void RadTreeView_LoadOnDemand(object sender, RadRoutedEventArgs e) |
| { |
| //// This code exists as for some reason the |
| //// tree does not select the node being expanded. |
| //// This is normal but I can seem to set a |
| //// expand+select switch on the tree |
| var item = e.Source as RadTreeViewItem; |
| if (item == null) return; |
| // Expand the node |
| item.IsSelected = true; |
| } |
