System.Windows.DependencyProperty.GetDefaultValue C# (CSharp) Method

GetDefaultValue() private method

private GetDefaultValue ( Kind kind ) : object
kind Kind
return object
        internal virtual object GetDefaultValue(Kind kind)
        {
            IntPtr ptr;
            object ret = null;

            // The value from GetDefaultValue does not need to be deleted
            ptr = Mono.NativeMethods.dependency_property_get_default_value (native, kind);
            if (ptr == IntPtr.Zero) {
                // The value from GetAutoCreatedValue does need to be deleted
                ptr = NativeMethods.dependency_property_get_auto_created_value (native, kind, IntPtr.Zero);
                ret = Value.ToObject (ptr);
                NativeMethods.value_delete_value2 (ptr);
            } else {
                ret = Value.ToObject (PropertyType, ptr);
            }

            return ret;
        }

Same methods

DependencyProperty::GetDefaultValue ( object ob ) : object

Usage Example

Beispiel #1
0
        static void InvokeChangedCallback(DependencyObject obj, DependencyProperty property, PropertyChangedCallback callback,
                                          object old_obj, object new_obj)
        {
            if (old_obj == null && property.property_type.IsValueType && !property.IsNullable)
            {
                old_obj = property.GetDefaultValue(obj);
                Console.WriteLine("WARNING: Got a null value for {0}.{1} which is a value type", property.DeclaringType.Name, property.Name);
            }

            if (Helper.AreEqual(property.PropertyType, old_obj, new_obj))
            {
                return;
            }

            var args = new DependencyPropertyChangedEventArgs(old_obj, new_obj, property);

            // note: since callbacks might throw exceptions but we cannot catch them
            callback(obj, args);
        }
All Usage Examples Of System.Windows.DependencyProperty::GetDefaultValue