private static void DecomposeException(ObservableCollection <DataElementModel> collection, int depth
                                                   , DataElementModel root, DataElementModel model, Exception e)
            {
                model.Value = e.Message;

                var callstack_model = new DataElementModel
                {
                    Parent = model,
                    Level  = model.Level + ".Stack",
                    Value  = GetStackTrace(e),
                };

                collection.Add(callstack_model);

                if (e.InnerException != null)
                {
                    depth++;
                    var inner_model = new DataElementModel
                    {
                        Parent = model,
                        Level  = string.Format("{0}.{1}", root.Level, depth),
                    };
                    collection.Add(inner_model);

                    DecomposeException(collection, depth, root, inner_model, e.InnerException);
                }
            }
        private static void OnDataArrayPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var ctrl   = (TraceDataArrayControl)d;
            var source = (object[])e.NewValue;

            ctrl.DataElements.Clear();
            if (!source.IsNullOrEmpty())
            {
                DataElementModel.Populate(ctrl.DataElements, source);
            }
        }
            public static void Populate(ObservableCollection <DataElementModel> collection, object[] source)
            {
                for (int x = 0; x < source.Length; x++)
                {
                    var src   = source[x];
                    var model = new DataElementModel
                    {
                        Parent = null,
                        Level  = x.ToString(),
                    };
                    collection.Add(model);

                    if (src is Exception)
                    {
                        DecomposeException(collection, 0, model, model, (Exception)src);
                    }
                    else
                    {
                        model.Value = src.ToString();
                    }
                }
            }