I have an ObservableCollection binded to a template in WCF's XAML view. I need to be able to randomly change elements in it by their names
Currently I have two collections, one ObservableCollection<MyElement>
and another one Dictionary<String, MyElement>
which translates names for elements
Everything's working fine but I needed to make some functions to keep integrity between those two collections; such as:
void AddElement(MyElement a)
{
dictionary.Add(a.Name, a);
observableCollection.Insert(0, a);
}
is there a better way of doing it? I know I can use LINQ to query it, but it still will internally use iterating over each element to find the element I need - I need a faster way