private void WiFiListView_SelectionChanged(object sender, SelectionChangedEventArgs e) { var listView = sender as ListView; var connectedNetwork = _networkPresenter.GetOOBECurrentWifiNetwork(); foreach (var item in e.RemovedItems) { if (connectedNetwork == item) { SwitchToItemState(item, WiFiConnectedState, true); } else { SwitchToItemState(item, WiFiInitialState, true); } } foreach (var item in e.AddedItems) { _automatic = true; if (connectedNetwork == item) { SwitchToItemState(connectedNetwork, WiFiConnectedMoreOptions, true); } else { SwitchToItemState(item, WiFiConnectState, true); } } WiFiListView.ScrollIntoView(WiFiListView.SelectedItem); }
private ListViewItem SwitchToItemState(object dataContext, DataTemplate template, bool forceUpdate) { if (forceUpdate) { WiFiListView.UpdateLayout(); } var item = WiFiListView.ContainerFromItem(dataContext) as ListViewItem; if (item != null) { item.ContentTemplate = template; } return(item); }
private ListViewItem SwitchToItemState(object dataContext, DataTemplate template, bool forceUpdate) { if (WiFiConnectedState.Equals(template)) { ServiceUtil.TelemetryService.WriteEvent("WiFiConnectSuccess"); } if (forceUpdate) { WiFiListView.UpdateLayout(); } var item = WiFiListView.ContainerFromItem(dataContext) as ListViewItem; if (item != null) { item.ContentTemplate = template; } return(item); }