Пример #1
0
        static void OnSelectedItemChanged(Control sender, AttachedPropertyChangedEventArgs<object> e)
        {
            IItemsSourceFeature feature = sender.GetItemsSourceFeature();
            if(feature != null) {
                Action<Control> selectionChangedHandler = sender.GetValue(HandlerProperty);
                if(selectionChangedHandler == null) {
                    selectionChangedHandler = OnSelectionChanged;
                    sender.SetValue(HandlerProperty, selectionChangedHandler);
                    feature.AddSelectionChangedCallback(sender, selectionChangedHandler);
                }

                feature.SetSelectedItem(sender, e.NewValue);
                sender.SetSelectedItem(feature.GetSelectedItem(sender));
                //TODO test recursion or add assert
            }
        }
Пример #2
0
 static void OnSelectionChanged(Control sender)
 {
     IItemsSourceFeature feature = sender.GetItemsSourceFeature();
     sender.SetSelectedItem(feature.GetSelectedItem(sender));
     //TODO test recursion or add assert
 }