示例#1
0
        private void DeleteSelectedItem()
        {
            if (MyAnimalList.SelectedItem != null)
            {
                MyAnimalList.Items.Remove(MyAnimalList.SelectedItem);

                if (MyAnimalList.Items.Count > 0)
                {
                    MyAnimalList.SelectedIndex = 0;
                }
                else
                {
                    EmptyListLabel.Visibility = Visibility.Visible;

                    // ACCESSIBILITY BUG FIX:
                    // Allow the keyboard focus to remain on the empty list, so that the customer using
                    // a screen reader knows immediately that the list is empty. So set the label just
                    // made visible to be the list's FullDescription, so that that also gets announced.

                    MyAnimalList.IsTabStop = true;

                    AutomationProperties.SetFullDescription(MyAnimalList, EmptyListLabel.Text);
                }

                MyAnimalList.Focus(FocusState.Programmatic);
            }
        }