Пример #1
0
        private static void HandleIsEnabledChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)
        {
            var textBlock = source as TextBlock;

            if (textBlock == null)
            {
                return;
            }

            if ((bool)e.OldValue)
            {
                var fader = GetFader(textBlock);
                if (fader != null)
                {
                    fader.Detach();
                    SetFader(textBlock, null);
                }

                textBlock.Loaded   -= HandleTextBlockLoaded;
                textBlock.Unloaded -= HandleTextBlockUnloaded;
            }

            if ((bool)e.NewValue)
            {
                textBlock.Loaded   += HandleTextBlockLoaded;
                textBlock.Unloaded += HandleTextBlockUnloaded;

                var fader = new Fader(textBlock);
                SetFader(textBlock, fader);
                fader.Attach();
            }
        }
Пример #2
0
        private static void HandleIsEnabledChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)
        {
            var textBlock = source as TextBlock;
            if (textBlock == null)
            {
                return;
            }

            if ((bool)e.OldValue)
            {
                var fader = GetFader(textBlock);
                if (fader != null)
                {
                    fader.Detach();
                    SetFader(textBlock, null);
                }

                textBlock.Loaded -= HandleTextBlockLoaded;
                textBlock.Unloaded -= HandleTextBlockUnloaded;
            }

            if ((bool)e.NewValue)
            {
                textBlock.Loaded += HandleTextBlockLoaded;
                textBlock.Unloaded += HandleTextBlockUnloaded;

                var fader = new Fader(textBlock);
                SetFader(textBlock, fader);
                fader.Attach();
            }
        }