public static DataContextProperty GetDataContextProperty(DocumentCompositeNode documentNode, IProperty property) { DataContextProperty dataContextProperty = DataContextMetadata.GetDataContextPropertyInternal(documentNode, property); if (dataContextProperty != null && dataContextProperty.IsValid && documentNode.Properties[(IPropertyId)property] != null) { DualDataContextAttribute contextAttribute = DataContextMetadata.GetDataContextAttribute <DualDataContextAttribute>(property); if (contextAttribute != null && contextAttribute.UseDefaultDataContextWhenValueSet) { dataContextProperty = (DataContextProperty)null; } } return(dataContextProperty); }
private RawDataSourceInfoBase MoveToDataContextProperty(IDataContextAncestorWalker walker, RawDataSourceInfoBase localDataSource) { if (walker.CurrentNode == null) { return((RawDataSourceInfoBase)null); } DataContextProperty dataContextProperty = DataContextMetadata.GetDataContextProperty(walker.CurrentNode, walker.CurrentProperty); if (dataContextProperty == null) { return((RawDataSourceInfoBase)null); } if (!dataContextProperty.IsValid) { return((RawDataSourceInfoBase)RawDataSourceInfo.Invalid); } if (this.visitedLocations.IsVisited(walker)) { return((RawDataSourceInfoBase)RawDataSourceInfo.Invalid); } DocumentNode dataContextNode = dataContextProperty.DataContextNode; if (dataContextNode == null) { return((RawDataSourceInfoBase)RawDataSourceInfo.Invalid); } this.OnDataSourceFound(walker.CurrentNode, walker.CurrentProperty); RawDataSourceInfoBase rawDataSourceInfo = DataContextHelper.GetRawDataSourceInfo(dataContextNode); if (rawDataSourceInfo.IsValid && dataContextProperty.IsCollectionItem) { rawDataSourceInfo.AppendIndexStep(); } RawDataSourceInfoBase localDataSource1 = rawDataSourceInfo.CombineWith(localDataSource); walker.MoveTo(dataContextProperty.SourceNode, dataContextProperty.Property, true); return(this.UnwindElementNameBindingInternal(walker, localDataSource1)); }