c# - Having trouble adding to an ObservableCollection using Dispatcher of UI thread -
After
A lot of questions (primarily ObservableCollection
) While using a background worker thread I am trying to apply however, my position has a slightly higher depth because it calls a function in the edition that gives the object to include.
This is bound to my solution looks like now ( Note that my ObservableCollection
a TreeView
control ):
// Pass Background Thread from MainTreeViewModel.AddLocation (LocationName, locationValue); // UI thread (MainTreeViewModel) public void AddLocation (MultiItemString DISPLAYNAME, integer locationValue) {var node = Data.GetAllChildren (X = & gt; x.Children) .. .Distinct () ToList () First (x => X. Identification == 'P'); // Area Parent App.Current.Dispatcher.BeginInvoke ((action) representatives () {node.Children.Add (CreateLocationNode (DISPLAYNAME, locationValue));}); }
CreateLocationNode:
// Also MainTreeViewModel private HierarchicalVM CreateLocationNode location (MultiItemString DISPLAYNAME, integer locationValue) {MultiItemString locationNumber = new MultiItemString (new [ ] {LocationValue.ToString () + ""}, false); Var newLocationNode = new HierarchicalVM () {DisplayName = DISPLAYNAME, as // props zero LocationNumber = locationNumber, TreeView_LocValue = locationValue, child = examples of new ObservableCollection is & lt turn out; HierarchicalVM & gt; (), // what it is being added in order =}; Place a new place; }
While doing this, I think that an object is added, but all the properties attached to it get zero values from the front, when I am doing everything in the UI thread And simply by using node.Children.Add (CreateLocationNode (displayName, locationValue));
, why am I getting a different result, and how can I fix it?
Please tell me that you need more code.
Comments
Post a Comment