2011-01-20 25 views
1

我有两页:P1和P2。列表框中的选定项从其他页返回后灰了

在P1,

一)从IsolatedStorage和数据绑定数据装入listBox1中采取按钮单击事件发生在P1。

b)中用户选择一个项目,被导航到P2

例如:用户在P2选择CarModel_1

: 用户按下返回键在P2返回到P1。

问题:

当从P2 returnning,在ListBox1中所选择的项目变为灰色或不被点击进入P2。

示例:CarModel_1变灰或不可点击。

其余的是可点击的。

感谢您对此的帮助。

感谢

回答

1
解决此问题

一种常见方法是将selectedIndex = -1列表框。

如果您创建一个默认的Databound项目,您可以看到这个动作。

这是生成的代码。

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; 
} 

另一种方法是实现此问题中概述的手势服务。

Is there a click behavior for a list?

+0

@Mick N:你知道为什么这种行为发生,如果你不重新选择?我很好奇...... – Praetorian 2011-01-20 07:11:23

相关问题