Esempio n. 1
0
        public XboxSongHistoryPage()
        {
            this.InitializeComponent();


            long itemsSourceHandler = 0;

            itemsSourceHandler = SongHistoryListView.RegisterPropertyChangedCallback(GridView.ItemsSourceProperty, new DependencyPropertyChangedCallback(async(obj, dp) =>
            {
                IEnumerable <object> collection = obj.GetValue(dp) as IEnumerable <object>;
                if (collection != null)
                {
                    //try and force focus on the first item when we load this page.
                    SongHistoryListView.UnregisterPropertyChangedCallback(GridView.ItemsSourceProperty, itemsSourceHandler);

                    if (collection.Count() == 0)
                    {
                        return;
                    }

                    //wait until we can get an item from the song history list view to focus. this is a hack but it'll have to do.
                    ListViewItem firstItem = null;

                    do
                    {
                        firstItem = (ListViewItem)SongHistoryListView.ContainerFromIndex(0);
                        await Task.Delay(50);
                    } while (firstItem == null);

                    firstItem.Focus(FocusState.Keyboard);

                    SongHistoryListView.SelectedIndex = 0;
                }
            }));
        }
Esempio n. 2
0
        public void PreserveFocus()
        {
            var selection = SongHistoryListView.SelectedItem;

            if (selection != null)
            {
                focusedItem = (ListViewItem)SongHistoryListView.ContainerFromItem(selection);
            }
        }