private static int GetFigureCount(PathElement pathElement) { if (pathElement == null || !pathElement.IsViewObjectValid) { return(0); } IPlatformTypes metadata = pathElement.Platform.Metadata; if (!PlatformTypes.IsInstance(pathElement.GetLocalValue(PathElement.DataProperty), PlatformTypes.PathGeometry, metadata.DefaultTypeResolver)) { return(pathElement.PathGeometry.Figures.Count); } object obj = new PropertyReference(new List <ReferenceStep>() { metadata.ResolveProperty(PathElement.DataProperty) as ReferenceStep, metadata.ResolveProperty(PathElement.FiguresProperty) as ReferenceStep, metadata.ResolveProperty(PathElement.PathFigureCollectionCountProperty) as ReferenceStep }).GetValue(pathElement.ViewObject.PlatformSpecificObject); if (obj is int) { return((int)obj); } return(0); }