diff --git a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/CompletionDataHelper.cs b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/CompletionDataHelper.cs
index cefd3f59aa..dc242f4d18 100644
--- a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/CompletionDataHelper.cs
+++ b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/CompletionDataHelper.cs
@@ -5,7 +5,7 @@
// $Revision$
//
-using ICSharpCode.SharpDevelop.Project;
+using ICSharpCode.AvalonEdit.Document;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -16,6 +16,7 @@ using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
+using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.XmlEditor;
using LoggingService = ICSharpCode.Core.LoggingService;
@@ -45,11 +46,15 @@ namespace ICSharpCode.XamlBinding
{
int offset = Utils.GetOffsetFromFilePos(text, line, col);
+ if (offset == -1)
+ throw new InvalidOperationException("No valid file position: " + line + " " + col);
ParseInformation info = ParserService.GetParseInformation(fileName);
XmlElementPath path = XmlParser.GetActiveElementStartPathAtIndex(text, offset);
string attribute = XmlParser.GetAttributeNameAtIndex(text, offset);
- string attributeValue = XmlParser.GetAttributeValueAtIndex(text, offset);
bool inAttributeValue = XmlParser.IsInsideAttributeValue(text, offset);
+ string attributeValue = "";
+ if (inAttributeValue)
+ attributeValue = XmlParser.GetAttributeValueAtIndex(text, offset);
int offsetFromValueStart = Utils.GetOffsetFromValueStart(text, offset);
int elementStartIndex = XmlParser.GetActiveElementStartIndex(text, offset);
AttributeValue value = MarkupExtensionParser.ParseValue(attributeValue);
@@ -64,7 +69,7 @@ namespace ICSharpCode.XamlBinding
if (text[offset] == '>')
description = XamlContextDescription.None;
- if (!string.IsNullOrEmpty(attribute) || (elementStartIndex > -1 && offset > 0 && char.IsWhiteSpace(text[offset - 1])))
+ if (elementStartIndex > -1 && (char.IsWhiteSpace(text[offset]) || !string.IsNullOrEmpty(attribute) || Extensions.Is(text[offset], '"', '\'')))
description = XamlContextDescription.InTag;
if (inAttributeValue) {
@@ -98,8 +103,6 @@ namespace ICSharpCode.XamlBinding
ParseInformation = info
};
- LoggingService.Debug(context);
-
return context;
}
@@ -157,12 +160,8 @@ namespace ICSharpCode.XamlBinding
}
foreach (string @namespace in content.NamespaceNames) {
- if (!string.IsNullOrEmpty(@namespace)) {
- if (string.IsNullOrEmpty(content.AssemblyName))
- list.Add(new XmlnsCompletionItem(@namespace, false));
- else
+ if (!string.IsNullOrEmpty(@namespace))
list.Add(new XmlnsCompletionItem(@namespace, content.AssemblyName));
- }
}
}
diff --git a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/Extensions.cs b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/Extensions.cs
index c419fce30e..af671fcecf 100644
--- a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/Extensions.cs
+++ b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/Extensions.cs
@@ -13,6 +13,7 @@ using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using ICSharpCode.XmlEditor;
+using System.Xml;
namespace ICSharpCode.XamlBinding
{
@@ -39,6 +40,36 @@ namespace ICSharpCode.XamlBinding
return false;
}
+ public static bool Is(char value, params char[] chars)
+ {
+ foreach (var c in chars) {
+ if (c == value)
+ return true;
+ }
+
+ return false;
+ }
+
+ public static void Remove(this XmlAttributeCollection coll, string name)
+ {
+ for (int i = 0; i < coll.Count; i++) {
+ if (coll[i].Name.Equals(name, StringComparison.Ordinal)) {
+ coll.RemoveAt(i);
+ i--;
+ }
+ }
+ }
+
+ public static void Remove(this XmlAttributeCollection coll, string name, string namespaceURI)
+ {
+ for (int i = 0; i < coll.Count; i++) {
+ if (coll[i].LocalName.Equals(name, StringComparison.Ordinal) && coll[i].NamespaceURI.Equals(namespaceURI, StringComparison.Ordinal)) {
+ coll.RemoveAt(i);
+ i--;
+ }
+ }
+ }
+
public static IEnumerable RemoveEvents(this IEnumerable list)
{
foreach (var item in list) {
diff --git a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/PowerToys/Commands/GroupIntoMenuBuilder.cs b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/PowerToys/Commands/GroupIntoMenuBuilder.cs
new file mode 100644
index 0000000000..ed138edda4
--- /dev/null
+++ b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/PowerToys/Commands/GroupIntoMenuBuilder.cs
@@ -0,0 +1,28 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Collections.Generic;
+using System.Windows.Controls;
+
+namespace ICSharpCode.XamlBinding.PowerToys.Commands
+{
+ ///
+ /// Description of GroupIntoMenuBuilder
+ ///
+ public class GroupIntoMenuBuilder : XamlMenuBuilder
+ {
+ public override MenuItem[] BuildItems()
+ {
+ List