コード例 #1
0
ファイル: SelectionBehavior.cs プロジェクト: zoombapup/ATF
        /// <summary>
        /// Raises behavior Attached event and performs custom actions</summary>
        /// <param name="addeditems">Items added to selection</param>
        /// <param name="removedItems">Items removed to selection</param>
        protected override void OnAssociatedObjectSelectionChanged(IList addeditems, IList removedItems)
        {
            base.OnAssociatedObjectSelectionChanged(addeditems, removedItems);

            if (!m_synchronising)
            {
                try
                {
                    m_synchronising = true;

                    if (SelectionContext != null)
                    {
                        if (m_associatedObjectSelection != null)
                        {
                            // In muti select mode remove specific items
                            if (removedItems.Count > 0)
                            {
                                var converted = ConvertToSelectionContext(removedItems);
                                SelectionContext.RemoveRange(converted);
                            }
                        }
                        else
                        {
                            // In single select mode always clear selection
                            SelectionContext.Clear();
                        }

                        if (addeditems.Count > 0)
                        {
                            var converted = ConvertToSelectionContext(addeditems);
                            SelectionContext.AddRange(converted);
                        }
                    }
                }
                finally
                {
                    m_synchronising = false;
                }
            }
        }