Ejemplo n.º 1
0
        private static void ProgressChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            //Workaround for IsEnabled to not work correctly when Command state sets children of the progress control while progress is shown (thus content root is set to IsEnabled=false)
            ProgressControl ProgressControl = (ProgressControl)d;

            if (e.NewValue == null)
            {
                //Progress is hidden. Template sets the ISEnabled back, we have to refresh the Buttons & Hypelink states (see issue description above)
                UIElement Content = ProgressControl.Template.FindName("Content", ProgressControl) as UIElement;
                Content?.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (Action) delegate { ProgressControl.Update(Content); });
            }
            else
            {
                //Progress is shown. Template will handle
            }
        }
Ejemplo n.º 2
0
        private static void Update(UIElement element)
        {
            foreach (DependencyObject Child in element.GetVisualDescendantsDepthFirst <DependencyObject>())
            {
                if (Child is TextBlock)
                {
                    foreach (Inline Inline in ((TextBlock)Child).Inlines)
                    {
                        if (Inline is InlineUIContainer)
                        {
                            ProgressControl.Update(((InlineUIContainer)Inline).Child);
                        }

                        Inline.InvalidateProperty(UIElement.IsEnabledProperty);
                    }
                }
                Child.InvalidateProperty(UIElement.IsEnabledProperty);
            }
        }