private void WriteSpecificAttribute(XmlWriter writer, XmlAttribute attribute, List <StyleResource> styleResources) { if (ParsingHelper.IsStyleAttribute(attribute)) { BindingLanguageParser compiler = new BindingLanguageParser(); bool result; Expression resultExpression = compiler.Parse(attribute.Value, out result); if (!result) { throw new CompileException(string.Format("Can not compile expression {0}", attribute.Value)); } if (!resultExpression.IsOfType(ExpressionType.Resource)) { throw new CompileException(string.Format("Expecting resource expression for style, got {0}", attribute.Value)); } string resourceKey = resultExpression.GetValue(ResourceExpression.KEY); //find correct resource StyleResource styleResource = styleResources.FirstOrDefault(x => resourceKey.Equals(x.Key, StringComparison.InvariantCultureIgnoreCase)); if (styleResource == null) { throw new IndexOutOfRangeException(string.Format("Resource with key {0} does not exists", resourceKey)); } foreach (XmlAttribute attr in styleResource.ResourceElement.Attributes.Where(x => !ParsingHelper.IsResourceKeyAttribute(x))) { // write all attributes embedded in the style WriteAttribute(writer, attr, styleResources); } } }
private void LoadResources() { StyleResource.Apply(Resources, ThemeType.FlatTheme); }