protected virtual void SubAreaControl_Leaving(object sender, WPFUserControl.AutoCompleteTextBoxControlEventArgs e)
        {
            if (SubjectLocationControl.ListBoxReadOnly)
            {
                // get the country / area / subarea names from UI
                var countryName = CountryControl.GetCurrentText();
                var areaName    = AreaControl.GetCurrentText();
                var subAreaName = SubAreaControl.GetCurrentText();

                // get country object from UI
                if (CountryControl.GetCurrentObject() is Country country)
                {
                    // find the corresponding subject location (need to match country, area and subarea)
                    var subjectLocations = country.SubjectLocations.Where(c => c.Country.Name == countryName && c.Area.Name == areaName && c.SubArea.Name == subAreaName).ToList();

                    // valid subject Locations
                    if (subjectLocations != null)
                    {
                        // refresh control
                        RefreshControl(subjectLocations?.OfType <Location>().ToList(), SubjectLocationControl);
                    }
                }
            }
            else
            {
                RefreshControl(_allSubjectLocations?.OfType <Location>().ToList(), SubjectLocationControl);
            }

            // take subarea name from subarea object (if in database) or from UI text
            SetSubAreaDisplayItem(e.Object is SubArea subArea ? subArea.Name : SubAreaControl.GetCurrentText());

            SubjectLocationControl.SetFocus();
        }
        protected virtual void AreaControl_Leaving(object sender, WPFUserControl.AutoCompleteTextBoxControlEventArgs e)
        {
            if (SubAreaControl.ListBoxReadOnly)
            {
                // get the subareas and let the base class do the work
                var countrySubAreas = (CountryControl.GetCurrentObject() as Country)?.SubAreas;
                var areaSubAreas    = (e.Object as Area)?.SubAreas;

                // valid subareas
                if ((areaSubAreas != null) && (countrySubAreas != null))
                {
                    // get the subareas belong to both selected area and selected country
                    if (GetCountrySubAreas(areaSubAreas.ToList(), countrySubAreas.ToList()) is List <SubArea> matchingSubareas)
                    {
                        // refresh control
                        RefreshControl(matchingSubareas.OfType <Location>().ToList(), SubAreaControl);
                    }
                }
            }
            else
            {
                RefreshControl(_allSubAreas.OfType <Location>().ToList(), SubAreaControl);
            }

            // derived class can set the view model property
            // take area name from area object (if in database) or from UI text
            SetAreaDisplayItem(e.Object is Area area? area.Name : AreaControl.GetCurrentText());

            // set focus to the respective text box
            SubAreaControl.SetFocus();
        }
        protected virtual void CountryControl_Leaving(object sender, WPFUserControl.AutoCompleteTextBoxControlEventArgs e)
        {
            // if area control is ready only, only area of the assigned country can be selected
            if (AreaControl.ListBoxReadOnly)
            {
                RefreshControl((e.Object as Country)?.Areas?.OfType <Location>().ToList(), AreaControl);
            }
            // otherwise all existing areas can be selected (or new onces can be entered)
            else
            {
                RefreshControl(_allAreas.OfType <Location>().ToList(), AreaControl);
            }

            // clear old text
            SubAreaControl.ClearText();
            SubjectLocationControl.ClearText();
            SubjectLocationLatitudeControl.Text  = null;
            SubjectLocationLongitudeControl.Text = null;

            // derived class can set the view model property
            // take country name from country object (if in database) or from UI text
            SetCountryDisplayItem(e.Object as Country != null ? (e.Object as Country).Name : CountryControl.GetCurrentText());

            // set focus to the respective text box
            AreaControl.SetFocus();
        }
 private void AreaControl_LeavingViaShift(object sender, WPFUserControl.AutoCompleteTextBoxControlEventArgs e)
 {
     Window.Location_CountryControl.SetFocus();
 }
 protected virtual void SubjectLocationControl_Leaving(object sender, WPFUserControl.AutoCompleteTextBoxControlEventArgs e)
 {
     // take subject location name from subject location object (if in database) or from UI text
     SetSubjectLocationDisplayItem(e.Object is SubjectLocation subjectLocation ? subjectLocation.Name : SubjectLocationControl.GetCurrentText());
 }
 protected virtual void SubAreaControl_LeavingViaShift(object sender, WPFUserControl.AutoCompleteTextBoxControlEventArgs e)
 {
     AreaControl.SetFocus();
 }