Open johnmurphy01 opened 7 years ago
Seems like you should start by debugging the TreeViewItem code to see what is null and then figure out why. If you're currently using NuGet I would try to grab the sources instead and include them in your solution. It makes debugging easier.
Here are the inspection results from TreeItemView.cs in method CheckForSelectedDescendents
line 700. The properties IsExpanded
and IsSelected
are null from the TreeItemView. My data context looks correct and the values of open and selected are populated. Is there some additional configuration that has to happen in order to use IsExpanded and IsSelected? If I removed the modifications I made to the Style, everything is okay. Here's the structure of my data:
public class TreeChildren: INotifyPropertyChanged
{
public int nodeId { get; set; }
public string name { get; set; }
public int nodeDetailTypeId { get; set; }
public int nodeTypeId { get; set; }
public int treeId { get; set; }
public int parent { get; set; }
public int rank { get; set; }
public bool isDeleted { get; set; }
public int MaxDepth { get; set; }
public string namePath { get; set; }
public bool open { get; set; }
public List<TreeChildren> children { get; set; }
public bool selected { get; set; }
public FontAwesome.UWP.FontAwesomeIcon icon
{
get
{
if (open)
{
return FontAwesome.UWP.FontAwesomeIcon.FolderOutlinepenOutline;
}
return FontAwesome.UWP.FontAwesomeIcon.FolderOutline;
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string name)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
}
And I'm just setting the ItemsSource of the treeview to my data.
Again, you should look at the source of the toolkit and at the details of the exception stack. The problem is more than likely in the toolkit code and you'd need to fix the toolkit to address your problem.
Hi, Can someone guide me how programmatically expand and collapse the tree and subtrees? My app also a UWP and I currently do not use a property called IsExpand.
You get a TreeViewItem for your node and set its IsExpanded value. You can also use IsExpandedBindingPath if your nodes are generated in the view model. I think there might be examples in the debugging tools project.
On Wed, Mar 14, 2018 at 1:47 AM, Suren Saluka Manawatta < notifications@github.com> wrote:
Hi, Can someone guide me how programmatically expand and collapse the tree and subtrees? My app also a UWP and I currently do not use a property called IsExpand.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/xyzzer/WinRTXamlToolkit/issues/48#issuecomment-372945871, or mute the thread https://github.com/notifications/unsubscribe-auth/ABrAsCUcfWTzkwNdy8GSZWaX6SJxk1xAks5teNkVgaJpZM4N7cqd .
I am attempting to override the style of the treeview and the treeview items. I have copied the styles from https://github.com/xyzzer/WinRTXamlToolkit/blob/master/WinRTXamlToolkit/Controls/TreeView/TreeViewItem.xaml and https://github.com/xyzzer/WinRTXamlToolkit/blob/master/WinRTXamlToolkit/Controls/TreeView/TreeView.xaml
I added FontAwesome folder icons to control the expand collapse and removed the arrow toggle symbol. I added a couple of Setters for IsSelected and IsExpanded that are bound to two properties on my object that is part of the data source. However, when I run the application, I'm getting a null reference exception:
Here are the changes I made to the style. If I remove these the tree is rendered but I have no way of controlling expansion or selection:
This worked in WPF but I'm trying to create a UWP application from my existing source code and was not using the Toolkit prior to UWP. Please help!