Browse Source

- Fixed Bugs in XAML completion

- Added some Unit Tests for CC
- XAML binding is now aware of different WPF-XAML namespaces
- Detect used WPF-XAML namespace in XLinq based refactoring

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4966 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Siegfried Pammer 16 years ago
parent
commit
17117c781d
  1. 100
      src/AddIns/BackendBindings/XamlBinding/XamlBinding.Tests/CodeCompletionTests.cs
  2. 12
      src/AddIns/BackendBindings/XamlBinding/XamlBinding/CompletionDataHelper.cs
  3. 18
      src/AddIns/BackendBindings/XamlBinding/XamlBinding/Extensions.cs
  4. 4
      src/AddIns/BackendBindings/XamlBinding/XamlBinding/PowerToys/Commands/EditGridColumnsAndRowsCommand.cs
  5. 37
      src/AddIns/BackendBindings/XamlBinding/XamlBinding/PowerToys/Commands/ExtractPropertiesAsStyleCommand.cs
  6. 44
      src/AddIns/BackendBindings/XamlBinding/XamlBinding/PowerToys/Commands/GroupIntoRefactorings.cs
  7. 22
      src/AddIns/BackendBindings/XamlBinding/XamlBinding/PowerToys/Dialogs/EditGridColumnsAndRowsDialog.xaml.cs
  8. 3
      src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCodeCompletionBinding.cs
  9. 2
      src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCompletionItemList.cs

100
src/AddIns/BackendBindings/XamlBinding/XamlBinding.Tests/CodeCompletionTests.cs

@ -519,6 +519,106 @@ namespace ICSharpCode.XamlBinding.Tests @@ -519,6 +519,106 @@ namespace ICSharpCode.XamlBinding.Tests
});
}
[Test]
public void CtrlSpaceTest22()
{
string fileHeader = @"<Window x:Class='ICSharpCode.XamlBinding.Tests.CompletionTestsBase'
xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
<Window.Resources>
<Style TargetType='{x:Type Button}'>
<Setter Property='";
string fileFooter = @"'
</Style>
</Window.Resources>
<Grid>
<Button AllowDrop='True' Grid.Row='0' Content='test ' />
</Grid>
</Window>";
TestCtrlSpace(fileHeader, fileFooter, true,
list => {
Assert.AreEqual(0, list.PreselectionLength);
Assert.IsNull(list.SuggestedItem);
Assert.IsTrue(list.Items.Any());
});
}
[Test]
public void CtrlSpaceTest25()
{
string fileHeader = @"<Window x:Class='ICSharpCode.XamlBinding.Tests.CompletionTestsBase'
xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
<Window.Resources>
<Style TargetType='{x:Type Button}'>
<Setter Property='AllowDrop' Value'";
string fileFooter = @"'
</Style>
</Window.Resources>
<Grid>
<Button AllowDrop='True' Grid.Row='0' Content='test ' />
</Grid>
</Window>";
TestCtrlSpace(fileHeader, fileFooter, true,
list => {
Assert.AreEqual(0, list.PreselectionLength);
Assert.IsNull(list.SuggestedItem);
Assert.IsTrue(list.Items.Any());
});
}
[Test]
public void CtrlSpaceTest23()
{
string fileHeader = @"<Window x:Class='ICSharpCode.XamlBinding.Tests.CompletionTestsBase'
xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
<Window.Resources>
<Style TargetType='Button'>
<Setter Property='";
string fileFooter = @"'
</Style>
</Window.Resources>
<Grid>
<Button AllowDrop='True' Grid.Row='0' Content='test ' />
</Grid>
</Window>";
TestCtrlSpace(fileHeader, fileFooter, true,
list => {
Assert.AreEqual(0, list.PreselectionLength);
Assert.IsNull(list.SuggestedItem);
Assert.IsTrue(list.Items.Any());
});
}
[Test]
public void CtrlSpaceTest24()
{
string fileHeader = @"<Window x:Class='ICSharpCode.XamlBinding.Tests.CompletionTestsBase'
xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
<Window.Resources>
<Style TargetType='Button'>
<Setter Property='AllowDrop' Value='";
string fileFooter = @"'
</Style>
</Window.Resources>
<Grid>
<Button AllowDrop='True' Grid.Row='0' Content='test ' />
</Grid>
</Window>";
TestCtrlSpace(fileHeader, fileFooter, true,
list => {
Assert.AreEqual(0, list.PreselectionLength);
Assert.IsNull(list.SuggestedItem);
Assert.IsTrue(list.Items.Any());
});
}
[Test]
public void TypeAtValueEndingInSpace()
{

12
src/AddIns/BackendBindings/XamlBinding/XamlBinding/CompletionDataHelper.cs

@ -57,9 +57,13 @@ namespace ICSharpCode.XamlBinding @@ -57,9 +57,13 @@ namespace ICSharpCode.XamlBinding
public const string XamlNamespace = "http://schemas.microsoft.com/winfx/2006/xaml";
/// <summary>
/// value: http://schemas.microsoft.com/winfx/2006/xaml/presentation
/// values: http://schemas.microsoft.com/winfx/2006/xaml/presentation,
/// http://schemas.microsoft.com/netfx/2007/xaml/presentation
/// </summary>
public const string WpfXamlNamespace = "http://schemas.microsoft.com/winfx/2006/xaml/presentation";
public static readonly string[] WpfXamlNamespaces = new[] {
"http://schemas.microsoft.com/winfx/2006/xaml/presentation",
"http://schemas.microsoft.com/netfx/2007/xaml/presentation"
};
/// <summary>
/// value: http://schemas.openxmlformats.org/markup-compatibility/2006
@ -677,9 +681,9 @@ namespace ICSharpCode.XamlBinding @@ -677,9 +681,9 @@ namespace ICSharpCode.XamlBinding
isExplicit = false;
for (int i = 0; i < ancestors.Count; i++) {
if (ancestors[i].LocalName == "Style" && ancestors[i].Namespace == WpfXamlNamespace) {
if (ancestors[i].LocalName == "Style" && WpfXamlNamespaces.Contains(ancestors[i].Namespace)) {
isExplicit = true;
return ancestors[i].GetAttributeValue(WpfXamlNamespace, "TargetType") ?? string.Empty;
return ancestors[i].GetAttributeValue("TargetType") ?? string.Empty;
}
if (ancestors[i].Name.EndsWithAny(elementName.Select(s => "." + s + "s"), StringComparison.Ordinal)

18
src/AddIns/BackendBindings/XamlBinding/XamlBinding/Extensions.cs

@ -52,6 +52,24 @@ namespace ICSharpCode.XamlBinding @@ -52,6 +52,24 @@ namespace ICSharpCode.XamlBinding
return element;
}
public static string[] GetCurrentNamespaces(this XElement element)
{
Dictionary<XName, string> active = new Dictionary<XName, string>();
var current = element;
while (current != null) {
var newAttributes = current.Attributes()
.Where(i => i.IsNamespaceDeclaration && !active.ContainsKey(i.Name))
.ToArray();
foreach (var item in newAttributes)
active.Add(item.Name, item.Value);
current = current.Parent;
}
return active.Select(pair => pair.Value).ToArray();
}
public static XElement MoveAfter(this XElement element, XNode target)
{
if (element == null)

4
src/AddIns/BackendBindings/XamlBinding/XamlBinding/PowerToys/Commands/EditGridColumnsAndRowsCommand.cs

@ -30,9 +30,9 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands @@ -30,9 +30,9 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands
XElement selectedItem = (from item in document.Root.Descendants()
where item.IsInRange(startLoc, endLoc) select item).FirstOrDefault();
if (selectedItem == null || selectedItem.Name != XName.Get("Grid", CompletionDataHelper.WpfXamlNamespace)) {
if (selectedItem == null || CompletionDataHelper.WpfXamlNamespaces.Select(item => XName.Get("Grid", item)).Any(ns => ns == selectedItem.Name)) {
selectedItem = document.Root.Elements().FirstOrDefault();
if (selectedItem == null || selectedItem.Name != XName.Get("Grid", CompletionDataHelper.WpfXamlNamespace)) {
if (selectedItem == null || CompletionDataHelper.WpfXamlNamespaces.Select(item => XName.Get("Grid", item)).Any(ns => ns == selectedItem.Name)) {
MessageService.ShowError("Please select a Grid!");
return false;
}

37
src/AddIns/BackendBindings/XamlBinding/XamlBinding/PowerToys/Commands/ExtractPropertiesAsStyleCommand.cs

@ -50,9 +50,12 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands @@ -50,9 +50,12 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands
document.Root.AddFirst(resourcesRoot);
}
string currentWpfXamlNamespace = resourcesRoot.GetCurrentNamespaces()
.First(i => CompletionDataHelper.WpfXamlNamespaces.Contains(i));
var selectedAttributes = attributes.Where(item => item.Selected);
resourcesRoot.AddFirst(CreateStyle(dialog.StyleName, selectedItem.Name.LocalName, selectedAttributes));
resourcesRoot.AddFirst(CreateStyle(dialog.StyleName, selectedItem.Name.LocalName, selectedAttributes, currentWpfXamlNamespace));
selectedAttributes.Where(p => p.Attribute != null).Select(prop => prop.Attribute).Remove();
selectedAttributes.Where(p => p.Element != null).Select(prop => prop.Element).Remove();
@ -98,9 +101,9 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands @@ -98,9 +101,9 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands
// TODO : make the methods xmlns independent
static XElement CreateStyle(string name, string targetType, IEnumerable<PropertyEntry> entries)
static XElement CreateStyle(string name, string targetType, IEnumerable<PropertyEntry> entries, string currentWpfXamlNamespace)
{
XElement style = new XElement(XName.Get("Style", CompletionDataHelper.WpfXamlNamespace));
XElement style = new XElement(XName.Get("Style", currentWpfXamlNamespace));
if (!string.IsNullOrEmpty(name))
style.SetAttributeValue(XName.Get("Key", CompletionDataHelper.XamlNamespace), name);
style.SetAttributeValue(XName.Get("TargetType"), targetType);
@ -108,49 +111,49 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands @@ -108,49 +111,49 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands
foreach (var entry in entries) {
if (entry.Attribute != null) {
if (entry.Member is IEvent)
style.Add(CreateEventSetter(entry.PropertyName, entry.PropertyValue));
style.Add(CreateEventSetter(entry.PropertyName, entry.PropertyValue, currentWpfXamlNamespace));
else
style.Add(CreateSetter(entry.PropertyName, entry.PropertyValue));
style.Add(CreateSetter(entry.PropertyName, entry.PropertyValue, currentWpfXamlNamespace));
} else {
if (entry.Member is IEvent)
style.Add(CreateExtendedEventSetter(entry.PropertyName, entry.PropertyValue));
style.Add(CreateExtendedEventSetter(entry.PropertyName, entry.PropertyValue, currentWpfXamlNamespace));
else
style.Add(CreateExtendedSetter(entry.PropertyName, entry.PropertyValue));
style.Add(CreateExtendedSetter(entry.PropertyName, entry.PropertyValue, currentWpfXamlNamespace));
}
}
return style;
}
static XElement CreateEventSetter(string eventName, string handler)
static XElement CreateEventSetter(string eventName, string handler, string currentWpfXamlNamespace)
{
XElement eventSetter = new XElement(XName.Get("EventSetter", CompletionDataHelper.WpfXamlNamespace));
XElement eventSetter = new XElement(XName.Get("EventSetter", currentWpfXamlNamespace));
eventSetter.SetAttributeValue(XName.Get("Event"), eventName);
eventSetter.SetAttributeValue(XName.Get("Handler"), handler);
return eventSetter;
}
static XElement CreateSetter(string property, string value)
static XElement CreateSetter(string property, string value, string currentWpfXamlNamespace)
{
XElement setter = new XElement(XName.Get("Setter", CompletionDataHelper.WpfXamlNamespace));
XElement setter = new XElement(XName.Get("Setter", currentWpfXamlNamespace));
setter.SetAttributeValue(XName.Get("Property"), property);
setter.SetAttributeValue(XName.Get("Value"), value);
return setter;
}
static XElement CreateExtendedEventSetter(string eventName, string handler)
static XElement CreateExtendedEventSetter(string eventName, string handler, string currentWpfXamlNamespace)
{
XElement eventSetter = new XElement(XName.Get("EventSetter", CompletionDataHelper.WpfXamlNamespace));
XElement eventSetter = new XElement(XName.Get("EventSetter", currentWpfXamlNamespace));
eventSetter.SetAttributeValue(XName.Get("Event"), eventName);
eventSetter.Add(new XElement(XName.Get("EventSetter.Handler", CompletionDataHelper.WpfXamlNamespace), handler));
eventSetter.Add(new XElement(XName.Get("EventSetter.Handler", currentWpfXamlNamespace), handler));
return eventSetter;
}
static XElement CreateExtendedSetter(string property, string value)
static XElement CreateExtendedSetter(string property, string value, string currentWpfXamlNamespace)
{
XElement setter = new XElement(XName.Get("Setter", CompletionDataHelper.WpfXamlNamespace));
XElement setter = new XElement(XName.Get("Setter", currentWpfXamlNamespace));
setter.SetAttributeValue(XName.Get("Property"), property);
setter.Add(new XElement(XName.Get("Setter.Value", CompletionDataHelper.WpfXamlNamespace), value));
setter.Add(new XElement(XName.Get("Setter.Value", currentWpfXamlNamespace), value));
return setter;
}
}

44
src/AddIns/BackendBindings/XamlBinding/XamlBinding/PowerToys/Commands/GroupIntoRefactorings.cs

@ -39,7 +39,7 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands @@ -39,7 +39,7 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands
{
protected override XElement CreateParent()
{
return new XElement(XName.Get("Border", CompletionDataHelper.WpfXamlNamespace));
return new XElement(XName.Get("Border", currentWpfNamespace));
}
}
@ -47,8 +47,8 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands @@ -47,8 +47,8 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands
{
protected override bool GroupInto(XElement parent, IEnumerable<XElement> children)
{
XElement newParent = new XElement(XName.Get("Grid", CompletionDataHelper.WpfXamlNamespace));
XElement newItem = new XElement(XName.Get("Border", CompletionDataHelper.WpfXamlNamespace), newParent);
XElement newParent = new XElement(XName.Get("Grid", currentWpfNamespace));
XElement newItem = new XElement(XName.Get("Border", currentWpfNamespace), newParent);
newParent.Add(children);
parent.Add(newItem);
@ -64,8 +64,8 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands @@ -64,8 +64,8 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands
{
protected override bool GroupInto(XElement parent, IEnumerable<XElement> children)
{
XElement newParent = new XElement(XName.Get("StackPanel", CompletionDataHelper.WpfXamlNamespace));
XElement newItem = new XElement(XName.Get("Border", CompletionDataHelper.WpfXamlNamespace), newParent);
XElement newParent = new XElement(XName.Get("StackPanel", currentWpfNamespace));
XElement newItem = new XElement(XName.Get("Border", currentWpfNamespace), newParent);
newParent.SetAttributeValue("Orientation", "Vertical");
@ -83,8 +83,8 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands @@ -83,8 +83,8 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands
{
protected override bool GroupInto(XElement parent, IEnumerable<XElement> children)
{
XElement newParent = new XElement(XName.Get("StackPanel", CompletionDataHelper.WpfXamlNamespace));
XElement newItem = new XElement(XName.Get("Border", CompletionDataHelper.WpfXamlNamespace), newParent);
XElement newParent = new XElement(XName.Get("StackPanel", currentWpfNamespace));
XElement newItem = new XElement(XName.Get("Border", currentWpfNamespace), newParent);
newParent.SetAttributeValue("Orientation", "Horizontal");
@ -112,6 +112,8 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands @@ -112,6 +112,8 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands
abstract class GroupIntoBase : XamlMenuCommand
{
protected string currentWpfNamespace;
protected override bool Refactor(ITextEditor editor, XDocument document)
{
if (editor.SelectionLength == 0) {
@ -127,6 +129,10 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands @@ -127,6 +129,10 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands
if (selectedItems.Any()) {
var parent = selectedItems.First().Parent;
currentWpfNamespace = parent.GetCurrentNamespaces()
.First(i => CompletionDataHelper.WpfXamlNamespaces.Contains(i));
var items = selectedItems.Where(i => i.Parent == parent);
return GroupInto(parent, items);
@ -181,7 +187,7 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands @@ -181,7 +187,7 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands
{
protected override XElement CreateParent()
{
return new XElement(XName.Get("Grid", CompletionDataHelper.WpfXamlNamespace));
return new XElement(XName.Get("Grid", currentWpfNamespace));
}
}
@ -189,7 +195,7 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands @@ -189,7 +195,7 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands
{
protected override XElement CreateParent()
{
return new XElement(XName.Get("Canvas", CompletionDataHelper.WpfXamlNamespace));
return new XElement(XName.Get("Canvas", currentWpfNamespace));
}
}
@ -197,7 +203,7 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands @@ -197,7 +203,7 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands
{
protected override XElement CreateParent()
{
return new XElement(XName.Get("DockPanel", CompletionDataHelper.WpfXamlNamespace));
return new XElement(XName.Get("DockPanel", currentWpfNamespace));
}
}
@ -205,7 +211,7 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands @@ -205,7 +211,7 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands
{
protected override XElement CreateParent()
{
return new XElement(XName.Get("UniformGrid", CompletionDataHelper.WpfXamlNamespace));
return new XElement(XName.Get("UniformGrid", currentWpfNamespace));
}
}
@ -213,7 +219,7 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands @@ -213,7 +219,7 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands
{
protected override XElement CreateParent()
{
return new XElement(XName.Get("Viewbox", CompletionDataHelper.WpfXamlNamespace));
return new XElement(XName.Get("Viewbox", currentWpfNamespace));
}
}
@ -221,7 +227,7 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands @@ -221,7 +227,7 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands
{
protected override XElement CreateParent()
{
return new XElement(XName.Get("WrapPanel", CompletionDataHelper.WpfXamlNamespace));
return new XElement(XName.Get("WrapPanel", currentWpfNamespace));
}
}
@ -229,7 +235,7 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands @@ -229,7 +235,7 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands
{
protected override XElement CreateParent()
{
var element = new XElement(XName.Get("StackPanel", CompletionDataHelper.WpfXamlNamespace));
var element = new XElement(XName.Get("StackPanel", currentWpfNamespace));
element.SetAttributeValue("Orientation", "Vertical");
return element;
}
@ -239,7 +245,7 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands @@ -239,7 +245,7 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands
{
protected override XElement CreateParent()
{
var element = new XElement(XName.Get("StackPanel", CompletionDataHelper.WpfXamlNamespace));
var element = new XElement(XName.Get("StackPanel", currentWpfNamespace));
element.SetAttributeValue("Orientation", "Horizontal");
return element;
}
@ -249,8 +255,8 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands @@ -249,8 +255,8 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands
{
protected override bool GroupInto(XElement parent, IEnumerable<XElement> children)
{
XElement newParent = new XElement(XName.Get("Grid", CompletionDataHelper.WpfXamlNamespace));
XElement newItem = new XElement(XName.Get("ScrollViewer", CompletionDataHelper.WpfXamlNamespace), newParent);
XElement newParent = new XElement(XName.Get("Grid", currentWpfNamespace));
XElement newItem = new XElement(XName.Get("ScrollViewer", currentWpfNamespace), newParent);
newParent.Add(children);
parent.Add(newItem);
@ -266,8 +272,8 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands @@ -266,8 +272,8 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands
{
protected override bool GroupInto(XElement parent, IEnumerable<XElement> children)
{
XElement newParent = new XElement(XName.Get("Grid", CompletionDataHelper.WpfXamlNamespace));
XElement newItem = new XElement(XName.Get("GroupBox", CompletionDataHelper.WpfXamlNamespace), newParent);
XElement newParent = new XElement(XName.Get("Grid", currentWpfNamespace));
XElement newItem = new XElement(XName.Get("GroupBox", currentWpfNamespace), newParent);
newParent.Add(children);
parent.Add(newItem);

22
src/AddIns/BackendBindings/XamlBinding/XamlBinding/PowerToys/Dialogs/EditGridColumnsAndRowsDialog.xaml.cs

@ -30,14 +30,13 @@ namespace ICSharpCode.XamlBinding.PowerToys.Dialogs @@ -30,14 +30,13 @@ namespace ICSharpCode.XamlBinding.PowerToys.Dialogs
/// </summary>
public partial class EditGridColumnsAndRowsDialog : Window
{
static readonly XName rowDefsName = XName.Get("Grid.RowDefinitions", CompletionDataHelper.WpfXamlNamespace);
static readonly XName colDefsName = XName.Get("Grid.ColumnDefinitions", CompletionDataHelper.WpfXamlNamespace);
readonly XName rowDefsName, colDefsName;
readonly XName rowDefName, colDefName;
static readonly XName rowDefName = XName.Get("RowDefinition", CompletionDataHelper.WpfXamlNamespace);
static readonly XName colDefName = XName.Get("ColumnDefinition", CompletionDataHelper.WpfXamlNamespace);
readonly XName gridRowName = XName.Get("Grid.Row");
readonly XName gridColName = XName.Get("Grid.Column");
static readonly XName gridRowName = XName.Get("Grid.Row");
static readonly XName gridColName = XName.Get("Grid.Column");
readonly string currentWpfNamespace;
XElement gridTree;
XElement rowDefitions;
@ -53,6 +52,15 @@ namespace ICSharpCode.XamlBinding.PowerToys.Dialogs @@ -53,6 +52,15 @@ namespace ICSharpCode.XamlBinding.PowerToys.Dialogs
{
InitializeComponent();
currentWpfNamespace = gridTree.GetCurrentNamespaces()
.First(i => CompletionDataHelper.WpfXamlNamespaces.Contains(i));
rowDefsName = XName.Get("Grid.RowDefinitions", currentWpfNamespace);
colDefsName = XName.Get("Grid.ColumnDefinitions", currentWpfNamespace);
rowDefName = XName.Get("RowDefinition", currentWpfNamespace);
colDefName = XName.Get("ColumnDefinition", currentWpfNamespace);
this.gridTree = gridTree;
this.rowDefitions = gridTree.Element(rowDefsName) ?? new XElement(rowDefsName);
this.colDefitions = gridTree.Element(colDefsName) ?? new XElement(colDefsName);
@ -93,7 +101,7 @@ namespace ICSharpCode.XamlBinding.PowerToys.Dialogs @@ -93,7 +101,7 @@ namespace ICSharpCode.XamlBinding.PowerToys.Dialogs
RebuildGrid();
}
static void NormalizeElementGridIndices(XElement element, int maxCols, int maxRows)
void NormalizeElementGridIndices(XElement element, int maxCols, int maxRows)
{
XAttribute a = element.Attribute(gridColName);
XAttribute b = element.Attribute(gridRowName);

3
src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCodeCompletionBinding.cs

@ -210,7 +210,8 @@ namespace ICSharpCode.XamlBinding @@ -210,7 +210,8 @@ namespace ICSharpCode.XamlBinding
var completionList = new XamlCompletionItemList();
completionList.PreselectionLength = editor.GetWordBeforeCaretExtended().Length;
if ((context.ActiveElement.Name == "Setter" || context.ActiveElement.Name == "EventSetter") && context.Attribute.Name == "Value")
if ((context.ActiveElement.Name == "Setter" || context.ActiveElement.Name == "EventSetter") &&
(context.Attribute.Name == "Property" || context.Attribute.Name == "Value"))
DoSetterAndEventSetterCompletion(context, completionList);
else if ((context.ActiveElement.Name.EndsWith("Trigger") || context.ActiveElement.Name == "Condition") && context.Attribute.Name == "Value")
DoTriggerCompletion(context, completionList);

2
src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCompletionItemList.cs

@ -79,7 +79,7 @@ namespace ICSharpCode.XamlBinding @@ -79,7 +79,7 @@ namespace ICSharpCode.XamlBinding
int spaces = CountWhiteSpacesAtEnd(context.Editor.GetWordBeforeCaret());
int typeNameStart = markup.ExtensionType.IndexOf(':') + 1;
if (!word.EndsWith(",", StringComparison.OrdinalIgnoreCase) && markup.ExtensionType.Substring(typeNameStart, markup.ExtensionType.Length - typeNameStart) != word) {
if (!(word == "." || word == "," || word == ":") && markup.ExtensionType.Substring(typeNameStart, markup.ExtensionType.Length - typeNameStart) != word) {
context.Editor.Document.Replace(context.Editor.Caret.Offset - spaces, spaces, ", ");
oldOffset += (2 - spaces);
}

Loading…
Cancel
Save