private void viewModel_RosterUpdated(object sender, EventArgs e)
        {
            CollectionViewSource source = (CollectionViewSource)(this.Resources["ParticipantsView"]);
            ListCollectionView   view   = (ListCollectionView)source.View;

            if (view != null && view.Groups != null && view.Groups.Count > 1)
            {
                view.Refresh();
                foreach (CollectionViewGroup cvg in view.Groups)
                {
                    if (rosterGroupExpansionStates.ContainsKey(cvg.Name.ToString()))
                    {
                        bool isExpanded = rosterGroupExpansionStates[cvg.Name.ToString()];
                        if (isExpanded)
                        {
                            GroupItem groupItem = this.RosterViewListBox.ItemContainerGenerator.ContainerFromItem(cvg) as GroupItem;
                            if (groupItem != null)
                            {
                                groupItem.UpdateLayout();
                                Expander expander = ControlUtilities.GetDescendantByType(groupItem, typeof(Expander)) as Expander;
                                if (expander != null)
                                {
                                    expander.IsExpanded = true;
                                }
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        private void viewModel_SequenceUpdated(object sender, EventArgs e)
        {
            CollectionViewSource source = (CollectionViewSource)(this.Resources["SequenceView"]);
            ListCollectionView   view   = (ListCollectionView)source.View;

            if (view != null && view.Groups != null && view.Groups.Count > 0)
            {
                view.Refresh();
                CollectionViewGroup cvg = view.Groups.First() as CollectionViewGroup;
                if (cvg.Name.ToString() == Constants.HOLDING_CHARACTERS_GROUP_NAME && view.Groups.Count > 1)
                {
                    cvg = view.Groups[1] as CollectionViewGroup;
                }
                GroupItem groupItem = this.SequenceViewListBox.ItemContainerGenerator.ContainerFromItem(cvg) as GroupItem;
                if (groupItem != null)
                {
                    groupItem.UpdateLayout();
                    Expander expander = Helper.GetDescendantByType(groupItem, typeof(Expander)) as Expander;
                    if (expander != null)
                    {
                        expander.IsExpanded = true;
                    }
                }
            }
        }