Skip to content

Instantly share code, notes, and snippets.

@ericsk
Last active December 16, 2015 09:28
Show Gist options
  • Select an option

  • Save ericsk/5412895 to your computer and use it in GitHub Desktop.

Select an option

Save ericsk/5412895 to your computer and use it in GitHub Desktop.
加入 OnSelectionChanged 的事件處理函式
...
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
ListView source = (ListView)sender;
// 如果要將選取的 focus 移開,改變 SelectedIndex 就可以
// 但就要處理被移開後不再重新呼叫 OnSelectionChanged
if (source.SelectedIndex != -1)
{
// 取得選取的資料項目
MessageModel message = (MessageModel)source.SelectedItem;
// 需要時移開註解使用
// source.SelectedIndex = -1;
}
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment