Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
345
XamDataTree reorder item with buttons and be selected/active after
posted

Hello,

I have a delegate command that moves a node up or down. I want the item to be active after reordering in order to use the keyboard arrow keys to navigate through the other items. How can i achieve that? I tried to bind the ActiveDataItem property in the XamDataTree with my ActiveItem property in the VM but with no result.

public DelegateCommand<object> MoveUpCommand { get; set; }

MoveUpCommand = new DelegateCommand<object>(OnMoveUp, CanMoveUp);

 public NodeItem ActiveItem { get; set; }

 private void OnMoveUp(object obj)
        {
            var item = obj as NodeItem;
            var index = Nodes.IndexOf(item);
            Nodes.Move(index, index+ 1);
            ActiveItem = item;
        }

        private bool CanMoveUp(object obj)
        {
            var item = obj as ActiveItem;
            return Nodes.IndexOf(item) != 0;          
        }

  • 6759
    Suggested Answer
    Offline posted

    Hello,

    I've just did a quick test re-ordering two items and then setting one of them as an active and it seems to be working. Could you take a look at the sample project I was using and modify it so it illustrate the issue that you're seeing or provide a sample of your own.

    I'm basically re-ordering the third and forth node at the root level and activating the one that is going up and doing this at a button click an it all seem to be behaving as expected.

    Hope this helps.

    XamDataTree_reOrderingAndActivatingNodes.zip