Read the error message, it's pretty explicit:
System.InvalidOperationException: 'Items collection must be empty before using ItemsSource.'
You are setting the ItemsSource property of a collection (the Treeview) which already has data in it.
Check your XAML, or empty the Items Collection.