private void CreateExpanders() { log.Info($"Found {CurrentBridgeHueObjectsList.Count} objects in the bridge."); CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(CurrentBridgeHueObjectsList); view.GroupDescriptions?.Clear(); PropertyGroupDescription groupDesc = new TypeGroupDescription(); view.GroupDescriptions?.Add(groupDesc); log.Info($"Finished refreshing view."); }
public async Task Initialize(Resourcelink rl = null) { rlcvm.LinkCreatorModel.ShowID = WinHueSettings.settings.ShowID; rlcvm.LinkCreatorModel.Wrap = WinHueSettings.settings.WrapText; List <IHueObject> hr = await BridgesManager.Instance.SelectedBridge.GetAllObjectsAsync(); if (hr == null) { return; } ObservableCollection <IHueObject> listbrobj = new ObservableCollection <IHueObject>(); List <IHueObject> listobj = hr; switch (WinHueSettings.settings.Sort) { case WinHueSortOrder.Default: listbrobj = new ObservableCollection <IHueObject>(hr); break; case WinHueSortOrder.Ascending: listbrobj.AddRange(from item in listobj where item is Light orderby item.name ascending select item); listbrobj.AddRange(from item in listobj where item is Group orderby item.name ascending select item); listbrobj.AddRange(from item in listobj where item is Schedule orderby item.name ascending select item); listbrobj.AddRange(from item in listobj where item is Scene orderby item.name ascending select item); listbrobj.AddRange(from item in listobj where item is Sensor orderby item.name ascending select item); listbrobj.AddRange(from item in listobj where item is Rule orderby item.name ascending select item); listbrobj.AddRange(from item in listobj where item is Resourcelink orderby item.name ascending select item); break; case WinHueSortOrder.Descending: listbrobj.AddRange(from item in listobj where item is Light orderby item.name descending select item); listbrobj.AddRange(from item in listobj where item is Group orderby item.name descending select item); listbrobj.AddRange(from item in listobj where item is Schedule orderby item.name descending select item); listbrobj.AddRange(from item in listobj where item is Scene orderby item.name descending select item); listbrobj.AddRange(from item in listobj where item is Sensor orderby item.name descending select item); listbrobj.AddRange(from item in listobj where item is Rule orderby item.name descending select item); listbrobj.AddRange(from item in listobj where item is Resourcelink orderby item.name descending select item); break; default: goto case WinHueSortOrder.Default; } rlcvm.ListHueObjects = listbrobj; CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(rlcvm.ListHueObjects); view.GroupDescriptions?.Clear(); PropertyGroupDescription groupDesc = new TypeGroupDescription(); view.GroupDescriptions?.Add(groupDesc); CollectionView view2 = (CollectionView)CollectionViewSource.GetDefaultView(rlcvm.LinkCreatorModel.ListlinkObject); view2.GroupDescriptions?.Clear(); PropertyGroupDescription groupDesc2 = new TypeGroupDescription(); view2.GroupDescriptions?.Add(groupDesc2); if (rl != null) { rlcvm.Resourcelink = rl; } }