コード例 #1
0
        private static void OnDataContextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DescriptionViewer viewer = d as DescriptionViewer;

            if ((viewer != null) && (((e.OldValue == null) || (e.NewValue == null)) || !ReferenceEquals(e.OldValue.GetType(), e.NewValue.GetType())))
            {
                viewer.LoadMetadata(false);
            }
        }
コード例 #2
0
        private static void OnDescriptionPropertyChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e)
        {
            DescriptionViewer viewer = depObj as DescriptionViewer;

            if (viewer != null)
            {
                viewer.UpdateDescriptionState();
            }
        }
コード例 #3
0
        private static void OnPropertyPathPropertyChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e)
        {
            DescriptionViewer viewer = depObj as DescriptionViewer;

            if ((viewer != null) && viewer.Initialized)
            {
                viewer.LoadMetadata(false);
                viewer.ParseTargetValidState();
            }
        }
コード例 #4
0
        private static void OnIsValidPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DescriptionViewer viewer = d as DescriptionViewer;

            if ((viewer != null) && !viewer.AreHandlersSuspended())
            {
                viewer.SetValueNoCallback(IsValidProperty, e.OldValue);
                object[] args = new object[] { "IsValid" };
                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Properties.Resources.UnderlyingPropertyIsReadOnly, args));
            }
        }
コード例 #5
0
        private static void OnTargetPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DescriptionViewer dependencyObject = d as DescriptionViewer;

            if (dependencyObject != null)
            {
                bool flag = false;
                //TODO: review this logic
                //flag = e.NewValue == FocusManager.GetFocusedElement(Window.GetWindow(dependencyObject));
                flag = e.NewValue == FocusManager.GetFocusedElement(dependencyObject);
                if (dependencyObject.IsFocused != flag)
                {
                    dependencyObject.IsFocused = flag;
                }
                dependencyObject.LoadMetadata(false);
                FrameworkElement oldValue = e.OldValue as FrameworkElement;
                FrameworkElement newValue = e.NewValue as FrameworkElement;
                EventHandler <ValidationErrorEventArgs> handler = new EventHandler <ValidationErrorEventArgs>(dependencyObject.Target_BindingValidationError);
                RoutedEventHandler handler2 = new RoutedEventHandler(dependencyObject.Target_GotFocus);
                RoutedEventHandler handler3 = new RoutedEventHandler(dependencyObject.Target_LostFocus);
                if (oldValue != null)
                {
                    //oldValue.BindingValidationError -= handler;
                    oldValue.RemoveHandler(Validation.ErrorEvent, handler);
                    oldValue.GotFocus  -= handler2;
                    oldValue.LostFocus -= handler3;
                }
                if (newValue != null)
                {
                    //newValue.BindingValidationError += handler;
                    newValue.AddHandler(Validation.ErrorEvent, handler);
                    newValue.GotFocus  += handler2;
                    newValue.LostFocus += handler3;
                }
                dependencyObject.ParseTargetValidState();
            }
        }