public void Restores_Selection_On_Items_Reset() { var items = new ResettingCollection(new[] { "foo", "bar", "baz" }); var model = new SelectionModel <string> { Source = items }; var target = new SelectedItemsSync(model); model.SelectedIndex = 1; items.Reset(new[] { "baz", "foo", "bar" }); Assert.Equal(2, model.SelectedIndex); }
private static void SelectedItems_Changed(Selector selector, DpChangedEventArgs <IList> e) { SelectedItemsSync sync = GetSelectedItemsSync(selector); if (sync != null) { sync.ModelSelectedItems = e.NewValue; } else { SetSelectedItemsSync(selector, new SelectedItemsSync(selector, e.NewValue)); selector.Unloaded += Selector_Unloaded; } }
private static SelectedItemsSync CreateTarget( IEnumerable <string> items = null) { items ??= new[] { "foo", "bar", "baz" }; var model = new SelectionModel { Source = items }; model.SelectRange(new IndexPath(1), new IndexPath(2)); var target = new SelectedItemsSync(model); return(target); }
private static SelectedItemsSync CreateTarget( IEnumerable <string> items = null) { items ??= new[] { "foo", "bar", "baz" }; var model = new SelectionModel <string> { Source = items, SingleSelect = false }; model.SelectRange(1, 2); var target = new SelectedItemsSync(model); return(target); }
public void Handles_Null_Model_Source() { var model = new SelectionModel(); model.Select(1); var target = new SelectedItemsSync(model); var items = target.GetOrCreateItems(); Assert.Empty(items); model.Select(2); model.Source = new[] { "foo", "bar", "baz" }; Assert.Equal(new[] { "bar", "baz" }, items); }
public void Selected_Items_Can_Be_Set_Before_SelectionModel_Source() { var model = new SelectionModel <string>(); var target = new SelectedItemsSync(model); var items = new AvaloniaList <string> { "foo", "bar", "baz" }; var selectedItems = new AvaloniaList <string> { "bar" }; target.SelectedItems = selectedItems; model.Source = items; Assert.Equal(1, model.SelectedIndex); }
public void Handles_Null_Model_Source() { var model = new SelectionModel <string> { SingleSelect = false }; model.Select(1); var target = new SelectedItemsSync(model); var items = target.SelectedItems; Assert.Empty(items); model.Select(2); model.Source = new[] { "foo", "bar", "baz" }; Assert.Equal(new[] { "bar", "baz" }, items); }
public TreeView() { // Setting Selection to null causes a default SelectionModel to be created. Selection = null; _selectedItems = new SelectedItemsSync(Selection); }
private static void SetSelectedItemsSync(Selector d, SelectedItemsSync value) { d.SetValue(SelectedItemsSyncProperty, value); }
private static void SetSelectedItemsSync (Selector d, SelectedItemsSync value) { d.SetValue(SelectedItemsSyncProperty, value); }