Exemplo n.º 1
0
        private void RemoveBindingExpressions(BindingGroup bindingGroup, DependencyObject element)
        {
            if (element == null)
            {
                return; // no content, hence no bindings to remove
            }
            var bindingExpressions = bindingGroup.BindingExpressions;

            BindingExpressionBase[] bindingExpressionsCopy = new BindingExpressionBase[bindingExpressions.Count];
            bindingExpressions.CopyTo(bindingExpressionsCopy, 0);

            for (int i = 0; i < bindingExpressionsCopy.Length; i++)
            {
                // Check the binding's target element - it might have been GC'd
                // (this can happen when column-virtualization is enabled).
                // If so, fetching TargetElement will detach the binding and remove it
                // from the binding group's collection.  This side-effect is why we
                // loop through a copy of the original collection, and don't rely
                // on i to be a valid index into the original collection.
                if (DataGridHelper.BindingExpressionBelongsToElement <DataGridCell>(bindingExpressionsCopy[i], this))
                {
                    bindingExpressions.Remove(bindingExpressionsCopy[i]);
                }
            }
        }
        // Token: 0x060046EE RID: 18158 RVA: 0x00141D94 File Offset: 0x0013FF94
        private void RemoveBindingExpressions(BindingGroup bindingGroup, DependencyObject element)
        {
            if (element == null)
            {
                return;
            }
            Collection <BindingExpressionBase> bindingExpressions = bindingGroup.BindingExpressions;

            BindingExpressionBase[] array = new BindingExpressionBase[bindingExpressions.Count];
            bindingExpressions.CopyTo(array, 0);
            for (int i = 0; i < array.Length; i++)
            {
                if (DataGridHelper.BindingExpressionBelongsToElement <DataGridCell>(array[i], this))
                {
                    bindingExpressions.Remove(array[i]);
                }
            }
        }
Exemplo n.º 3
0
        // Token: 0x060048DF RID: 18655 RVA: 0x0014ABA8 File Offset: 0x00148DA8
        internal static bool ValidateWithoutUpdate(FrameworkElement element)
        {
            bool         flag         = true;
            BindingGroup bindingGroup = element.BindingGroup;
            DataGridCell dataGridCell = (element != null) ? (element.Parent as DataGridCell) : null;

            if (bindingGroup != null && dataGridCell != null)
            {
                Collection <BindingExpressionBase> bindingExpressions = bindingGroup.BindingExpressions;
                BindingExpressionBase[]            array = new BindingExpressionBase[bindingExpressions.Count];
                bindingExpressions.CopyTo(array, 0);
                foreach (BindingExpressionBase bindingExpressionBase in array)
                {
                    if (DataGridHelper.BindingExpressionBelongsToElement <DataGridCell>(bindingExpressionBase, dataGridCell))
                    {
                        flag = (bindingExpressionBase.ValidateWithoutUpdate() && flag);
                    }
                }
            }
            return(flag);
        }