private static void VerifyReadOnlyProperty(DependencyProperty dependencyProperty, DependencyPropertyKey dependencyPropertyKey) { if (dependencyProperty.IsReadOnly && (dependencyPropertyKey == null || dependencyPropertyKey.DependencyProperty != dependencyProperty || !DependencyProperty.IsValidReadOnlyKey(dependencyPropertyKey))) { throw new Granular.Exception("Can't modify the read-only dependency property \"{0}\" without its key", dependencyProperty); } }