コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: SelectorProps.cs プロジェクト: binki/Alba.Framework
        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;
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
ファイル: TreeView.cs プロジェクト: yahiheb/Avalonia
 public TreeView()
 {
     // Setting Selection to null causes a default SelectionModel to be created.
     Selection      = null;
     _selectedItems = new SelectedItemsSync(Selection);
 }
コード例 #9
0
 private static void SetSelectedItemsSync(Selector d, SelectedItemsSync value)
 {
     d.SetValue(SelectedItemsSyncProperty, value);
 }
コード例 #10
0
 private static void SetSelectedItemsSync (Selector d, SelectedItemsSync value)
 {
     d.SetValue(SelectedItemsSyncProperty, value);
 }