Browse Source

Merge branch 'master' into feature/ImageScaleMode

pull/1762/head^2
Jumar Macato 8 years ago
committed by GitHub
parent
commit
667d288cec
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      .gitignore
  2. 2
      src/Avalonia.Controls/Primitives/SelectingItemsControl.cs
  3. 7
      src/Gtk/Avalonia.Gtk3/KeyTransform.cs
  4. 22
      tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests.cs

5
.gitignore

@ -165,6 +165,11 @@ $RECYCLE.BIN/
#################
.idea
#################
## VS Code
#################
.vscode/
#################
## Cake
#################

2
src/Avalonia.Controls/Primitives/SelectingItemsControl.cs

@ -376,7 +376,7 @@ namespace Avalonia.Controls.Primitives
break;
case NotifyCollectionChangedAction.Reset:
SelectedIndex = IndexOf(e.NewItems, SelectedItem);
SelectedIndex = IndexOf(Items, SelectedItem);
break;
}
}

7
src/Gtk/Avalonia.Gtk3/KeyTransform.cs

@ -33,17 +33,24 @@ namespace Avalonia.Gtk.Common
{ GdkKey.Prior, Key.Prior },
//{ GdkKey.?, Key.PageDown }
{ GdkKey.End, Key.End },
{ GdkKey.KP_End, Key.End },
{ GdkKey.Home, Key.Home },
{ GdkKey.KP_Home, Key.Home },
{ GdkKey.Left, Key.Left },
{ GdkKey.KP_Left, Key.Left },
{ GdkKey.Up, Key.Up },
{ GdkKey.KP_Up, Key.Up },
{ GdkKey.Right, Key.Right },
{ GdkKey.KP_Right, Key.Right },
{ GdkKey.Down, Key.Down },
{ GdkKey.KP_Down, Key.Down },
{ GdkKey.Select, Key.Select },
{ GdkKey.Print, Key.Print },
{ GdkKey.Execute, Key.Execute },
//{ GdkKey.?, Key.Snapshot }
{ GdkKey.Insert, Key.Insert },
{ GdkKey.Delete, Key.Delete },
{ GdkKey.KP_Delete, Key.Delete },
{ GdkKey.Help, Key.Help },
//{ GdkKey.?, Key.D0 }
//{ GdkKey.?, Key.D1 }

22
tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests.cs

@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using Avalonia.Collections;
using Avalonia.Controls.Presenters;
@ -13,6 +14,7 @@ using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Markup.Data;
using Avalonia.UnitTests;
using Moq;
using Xunit;
namespace Avalonia.Controls.UnitTests.Primitives
@ -686,6 +688,26 @@ namespace Avalonia.Controls.UnitTests.Primitives
Assert.Null(KeyboardNavigation.GetTabOnceActiveElement((InputElement)panel));
}
[Fact]
public void Resetting_Items_Collection_Should_Retain_Selection()
{
var itemsMock = new Mock<List<string>>();
var itemsMockAsINCC = itemsMock.As<INotifyCollectionChanged>();
itemsMock.Object.AddRange(new[] { "Foo", "Bar", "Baz" });
var target = new SelectingItemsControl
{
Items = itemsMock.Object
};
target.SelectedIndex = 1;
itemsMockAsINCC.Raise(e => e.CollectionChanged += null, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
Assert.True(target.SelectedIndex == 1);
}
private FuncControlTemplate Template()
{
return new FuncControlTemplate<SelectingItemsControl>(control =>

Loading…
Cancel
Save