protected override IPropertyId GetDefaultPropertySelection() { Type type = this.BindingPath.Node.Type; IType dataType = (IType)null; SceneViewModel viewModel = this.TargetElement.ViewModel; if (type != (Type)null) { dataType = viewModel.ProjectContext.GetType(type); } if (dataType == null) { dataType = viewModel.ProjectContext.ResolveType(PlatformTypes.Object); } IProperty property = BindingPropertyHelper.GetDefaultBindingPropertyInfo(this.TargetElement, dataType).Property; if (this.targetBindableProperties.IndexOf((ReferenceStep)property) < 0) { property = (IProperty)null; } if (property == null && dataType != null) { foreach (ReferenceStep referenceStep in (IEnumerable <ReferenceStep>) this.targetBindableProperties) { if (BindingPropertyHelper.GetPropertyCompatibility((IProperty)referenceStep, dataType, (ITypeResolver)this.ViewModel.ProjectContext) != BindingPropertyCompatibility.None) { property = (IProperty)referenceStep; break; } } } return((IPropertyId)property); }
public static BindingPropertyMatchInfo GetDefaultBindingPropertyInfo(SceneNode sceneNode, IType dataType) { BindingPropertyMatchInfo bestProperty = new BindingPropertyMatchInfo((IProperty)null); IProperty property = sceneNode.ProjectContext.ResolveProperty(BaseFrameworkElement.DataContextProperty); for (IType type = sceneNode.Type; type != null; type = type.BaseType) { ReferenceStep propertyInternal = BindingPropertyHelper.GetDefaultBindingPropertyInternal(type.NearestResolvedType, sceneNode.ProjectContext); if (propertyInternal != null && BindingPropertyHelper.IsPropertyBindable(sceneNode, new PropertyReference(propertyInternal), BindingPropertyHelper.BindingType.Target)) { BindingPropertyMatchInfo propertyMatchInfo = new BindingPropertyMatchInfo((IProperty)propertyInternal); propertyMatchInfo.Compatibility = propertyInternal != property?BindingPropertyHelper.GetPropertyCompatibility(propertyMatchInfo, dataType, (ITypeResolver)sceneNode.ProjectContext) : BindingPropertyCompatibility.DataContext; bestProperty = BindingPropertyHelper.GetBetterProperty(bestProperty, propertyMatchInfo); } } return(bestProperty); }
public static BindingPropertyCompatibility GetPropertyCompatibility(IProperty property, IType dataType, ITypeResolver typeResolver) { return(BindingPropertyHelper.GetPropertyCompatibility(new BindingPropertyMatchInfo(property), dataType, typeResolver)); }