private void OnRollerSelectionChanging(object sender, SelectionChangingRoutedEventArgs e)
 {
     if (e.SelectedIndex == -1)
     {
         e.Cancel = true;
     }
 }
Exemple #2
0
        protected override void OnSelectionChanged(SelectionChangedEventArgs e)
        {
            var args = new SelectionChangingRoutedEventArgs(SelectionChangingEvent, e.RemovedItems, e.AddedItems, SelectedIndex);

            RaiseEvent(args);
            if (args.Cancel)
            {
                e.Handled = true;
                return;
            }
            foreach (var item in e.AddedItems)
            {
                var rollerItem = ItemContainerGenerator.ContainerFromItem(item) as RollerItem;
                if (rollerItem != null)
                {
                    rollerItem.InternalSetIsSelected(true);
                }
            }
            foreach (var item in e.RemovedItems)
            {
                var rollerItem = ItemContainerGenerator.ContainerFromItem(item) as RollerItem;
                if (rollerItem != null)
                {
                    rollerItem.InternalSetIsSelected(false);
                }
            }

            UpdateRoller();
            base.OnSelectionChanged(e);
        }