Browse Source

bugfix a few small issues:

- Remove unnecessary special ResourceDictionary wich handled when Key was not specified (now I specify always one)
- Find Properties and Events Not Only against the Instance also against the Element Type (This can be a different one, for Example ModernUiWindow instead of WindowClone)
- When Collection Instance is not set, create one (bug appeared in ModerUi ModernWindow)
pull/604/head
jogibear9988 11 years ago
parent
commit
513c7e1935
  1. 18
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs
  2. 12
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs
  3. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs

18
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs

@ -31,14 +31,6 @@ using System.Xml.XPath; @@ -31,14 +31,6 @@ using System.Xml.XPath;
namespace ICSharpCode.WpfDesign.XamlDom
{
public class TemplateHelperResourceDictionary : ResourceDictionary, IDictionary
{
void IDictionary.Add(object key, object value)
{
base.Add(key == null ? "$$temp&&§§%%__" : key, value);
}
}
public static class TemplateHelper
{
public static FrameworkTemplate GetFrameworkTemplate(XmlElement xmlElement, XamlObject parentObject)
@ -60,13 +52,13 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -60,13 +52,13 @@ namespace ICSharpCode.WpfDesign.XamlDom
break;
}
foreach (var dictentry in ns)
{
xmlElement.SetAttribute("xmlns:" + dictentry.Key, dictentry.Value);
}
var keyAttrib = xmlElement.GetAttribute("Key", XamlConstants.XamlNamespace);
if (string.IsNullOrEmpty(keyAttrib))
xmlElement.SetAttribute("Key", XamlConstants.XamlNamespace, "$$temp&&§§%%__");
var xaml = xmlElement.OuterXml;
xaml = "<tmp:TemplateHelperResourceDictionary xmlns=\"http://schemas.microsoft.com/netfx/2007/xaml/presentation\" xmlns:tmp=\"clr-namespace:ICSharpCode.WpfDesign.XamlDom;assembly=ICSharpCode.WpfDesign.XamlDom\">" + xaml + "</tmp:TemplateHelperResourceDictionary>";
xaml = "<ResourceDictionary xmlns=\"http://schemas.microsoft.com/netfx/2007/xaml/presentation\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\">" + xaml + "</ResourceDictionary>";
StringReader stringReader = new StringReader(xaml);
XmlReader xmlReader = XmlReader.Create(stringReader);
var xamlReader = new XamlXmlReader(xmlReader, parentObject.ServiceProvider.SchemaContext);

12
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs

@ -426,11 +426,23 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -426,11 +426,23 @@ namespace ICSharpCode.WpfDesign.XamlDom
PropertyDescriptorCollection propertyDescriptors = TypeDescriptor.GetProperties(instance);
PropertyDescriptor propertyInfo = propertyDescriptors[propertyName];
XamlProperty newProperty;
if (propertyInfo == null) {
propertyDescriptors = TypeDescriptor.GetProperties(this.elementType);
propertyInfo = propertyDescriptors[propertyName];
}
if (propertyInfo != null) {
newProperty = new XamlProperty(this, new XamlNormalPropertyInfo(propertyInfo));
} else {
EventDescriptorCollection events = TypeDescriptor.GetEvents(instance);
EventDescriptor eventInfo = events[propertyName];
if (eventInfo == null) {
events = TypeDescriptor.GetEvents(this.elementType);
eventInfo = events[propertyName];
}
if (eventInfo != null) {
newProperty = new XamlProperty(this, new XamlEventPropertyInfo(eventInfo));
} else {

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs

@ -704,6 +704,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -704,6 +704,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
else {
collectionInstance = collectionProperty.propertyInfo.GetValue(obj.Instance);
collectionProperty.ParserSetPropertyElement(element);
collectionInstance = collectionInstance ?? Activator.CreateInstance(collectionProperty.propertyInfo.ReturnType);
}
}

Loading…
Cancel
Save