Determines whether a specified value is acceptable for this dependency property's type, as checked against the property type provided in the original dependency property registration.

Namespace: System.Windows
Assembly: WindowsBase (in windowsbase.dll)

public bool IsValidType (
	Object value
public boolean IsValidType (
	Object value
public function IsValidType (
	value : Object
) : boolean
Sie können diese Methoden nicht in XAML verwenden.



The value to check.


true if the specified value is the registered property type or an acceptable derived type; otherwise, false.

A null value is a valid type for reference type dependency properties, or for a Nullable dependency property, and would return true for these cases. In cases where the dependency property is neither a reference nor a Nullable type, IsValidType will return false for a null value rather than raise an exception.

The following example uses IsValidType as a check before calling SetValue on the dependency property.

void TrySetValue(DependencyObject target, DependencyProperty dp, object providedValue) {
  if (dp.IsValidType(providedValue))
    target.SetValue(dp, providedValue);

Microsoft .NET Framework 3.0 wird unter Windows Vista, Microsoft Windows XP SP2 und Windows Server 2003 SP1 unterstützt.

.NET Framework

Unterstützt in: 3.0
© 2015 Microsoft