コード例 #1
0
        private static void RaiseVisualTreeChangedEvent(
            EventHandler <VisualTreeChangeEventArgs> visualTreeChanged,
            VisualTreeChangeEventArgs args,
            bool isPotentialOuterChange)
        {
            bool       savedIsVisualTreeChangedInProgress = s_IsVisualTreeChangedInProgress;
            HwndSource savedActiveHwndSource = s_ActiveHwndSource;

            try
            {
                s_IsVisualTreeChangedInProgress = true;

                if (isPotentialOuterChange)
                {
                    s_ActiveHwndSource = PresentationSource.FromDependencyObject(args.Parent) as System.Windows.Interop.HwndSource;
                }

                visualTreeChanged(null, args);
            }
            finally
            {
                s_IsVisualTreeChangedInProgress = savedIsVisualTreeChangedInProgress;
                s_ActiveHwndSource = savedActiveHwndSource;
            }
        }
コード例 #2
0
ファイル: VisualDiagnostics.cs プロジェクト: mind0n/hive
 internal static void OnVisualChildChanged(DependencyObject parent, DependencyObject child, bool isAdded)
 {
     EventHandler<VisualTreeChangeEventArgs> visualTreeChanged = VisualDiagnostics.s_visualTreeChanged;
     if (visualTreeChanged != null && VisualDiagnostics.IsVisualTreeChangeEnabled)
     {
         int index;
         VisualTreeChangeType changeType;
         if (isAdded)
         {
             index = VisualDiagnostics.GetChildIndex(parent, child);
             changeType = VisualTreeChangeType.Add;
         }
         else
         {
             // We cannot reliably get correct child index for a removed child. We'll force it to be -1;
             index = -1;
             changeType = VisualTreeChangeType.Remove;
         }
         VisualTreeChangeEventArgs args = new VisualTreeChangeEventArgs(parent, child, index, changeType);
         visualTreeChanged(null, args);
     }
 }
コード例 #3
0
        internal static void OnVisualChildChanged(DependencyObject parent, DependencyObject child, bool isAdded)
        {
            EventHandler <VisualTreeChangeEventArgs> visualTreeChanged = VisualDiagnostics.s_visualTreeChanged;

            if (visualTreeChanged != null && VisualDiagnostics.IsVisualTreeChangeEnabled)
            {
                int index;
                VisualTreeChangeType changeType;
                if (isAdded)
                {
                    index      = VisualDiagnostics.GetChildIndex(parent, child);
                    changeType = VisualTreeChangeType.Add;
                }
                else
                {
                    // We cannot reliably get correct child index for a removed child. We'll force it to be -1;
                    index      = -1;
                    changeType = VisualTreeChangeType.Remove;
                }
                VisualTreeChangeEventArgs args = new VisualTreeChangeEventArgs(parent, child, index, changeType);
                visualTreeChanged(null, args);
            }
        }