private void SetSecurityGroupLists(string menuItemID) {//used within method as to not fire a property change of the public object... //eventually we will set the public objects from these objects... List <SecurityGroup> availableSecurityGroupList = new List <SecurityGroup>(); List <SecurityGroup> assignedSecurityGroupList = new List <SecurityGroup>(); //used to house the MenuSecurities for selected menu List <MenuSecurity> menuSecurities = new List <MenuSecurity>(); //get all the Security Groups to allow us to omit them if they belong to the Menu Item allready... List <SecurityGroup> allSecurityGroups = new List <SecurityGroup>(); //get all security groups allSecurityGroups = _serviceAgent.GetSecurityGroupsReadyOnly(ClientSessionSingleton.Instance.CompanyID).ToList(); //set it to all we will remove the selected ones... availableSecurityGroupList = allSecurityGroups; //get menuSecurities for selected item... menuSecurities = _serviceAgent.GetMenuSecuritiesByMenuItemIDReadOnly(menuItemID, ClientSessionSingleton.Instance.CompanyID).ToList(); //loop MenuSecurity and add it's Security Group to assignedSecurityGroups... //then loop AllSecurityGroups and omit the Assigned one from the AvailableSecurityGroups foreach (MenuSecurity item in menuSecurities) { assignedSecurityGroupList.Add(item.SecurityGroup); foreach (SecurityGroup omitItem in allSecurityGroups) { if (omitItem.SecurityGroupID == item.SecurityGroupID) { availableSecurityGroupList.Remove(omitItem); break; } } } //set the public objects from method objects... AvailableSecurityGroupList = new ObservableCollection <SecurityGroup>(availableSecurityGroupList); AssignedSecurityGroupList = new ObservableCollection <SecurityGroup>(assignedSecurityGroupList); }