开发者

Selected Item in ListBox gray out after returning from other page

I have two pages : P1 and P2.

In P1,

a) Loading data from IsolatedStorage and DataBinding to listBox1 take place in Button click event in P1.

b) user select an item and be navigated to P2

example : user select CarModel_1

in P2: user press Back Key in P2 to return to P1.

The pro开发者_运维问答blem :

When returnning from P2, the Selected Item in ListBox1 becomes gray out or Not clickable to go to P2.

example : CarModel_1 becomes gray out or Not clickable.

The rest is clickable.

Appreciate your help on this.

Thanks


One common way around this problem is to set SelectedIndex = -1 for the listbox.

You can see this in action if you create a default Databound project.

This is the code that is produced.

private void MainListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    // If selected index is -1 (no selection) do nothing
    if (MainListBox.SelectedIndex == -1)
        return;

    // Navigate to the new page
    NavigationService.Navigate(new Uri("/DetailsPage.xaml?selectedItem=" + MainListBox.SelectedIndex, UriKind.Relative));

    // Reset selected index to -1 (no selection)
    MainListBox.SelectedIndex = -1;
}

The alternative to this is to implement the gesture service as outlined in this question.

Is there a click behavior for a list?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜