public Boolean AddLegendItem(String Text, DataChannel DataChannel) { var NewItem = new LegendItem(Text, DataChannel, item => { DataGraphLegend.Children.Remove(item); SomeThingChanged_private(); }); var Found = false; foreach (var Item in DataGraphLegend.Children) { if (NewItem.Equals(Item as LegendItem)) Found = true; } if (!Found) DataGraphLegend.Children.Add(NewItem); SomeThingChanged_private(); return Found; }