We have an API that creates a Forms TreeNode, the root for a Forms TreeView. This process takes a couple of seconds so the users normally do this in a separate thread. Works great.

Now we have a new user that uses WPF and wants the same Treeview. We created a new method, a copy of the windows forms method, made a few changes and the WPF treeview was created.

However the WPF code can't be created on a separate thread. Apparently all UI elements must be created on the dispatcher thread.

Am I missing something? This WPF Me.Loaded event code illustrates the problem

Code:
        t = Task.Run(Sub()
                         Dim tvI As New TreeViewItem 'errors here.
                         tvI.Items.Add("Root")
                     End Sub)