/// <summary>
        /// Ensures that the correct attribute filter controls are created based on the selected <see cref="StepType"/>.
        /// </summary>
        /// <param name="stepTypePicker">The <see cref="StepTypePicker"/>.</param>
        private void EnsureSelectedStepTypeControls(StepTypePicker stepTypePicker)
        {
            DynamicControlsPanel containerControl = stepTypePicker.Parent as DynamicControlsPanel;
            FilterField          filterControl    = containerControl.FirstParentControlOfType <FilterField>();

            // Get the EntityFields for the attributes associated with the selected StepType.
            var entityFields = GetStepAttributes(stepTypePicker.SelectedValueAsId());

            // Create the attribute selection dropdown.
            string           propertyControlId = string.Format("{0}_ddlProperty", containerControl.ID);
            RockDropDownList ddlProperty       = containerControl.Controls.OfType <RockDropDownList>().FirstOrDefault(a => a.ID == propertyControlId);

            if (ddlProperty == null)
            {
                ddlProperty                       = new RockDropDownList();
                ddlProperty.ID                    = propertyControlId;
                ddlProperty.AutoPostBack          = true;
                ddlProperty.SelectedIndexChanged += ddlProperty_SelectedIndexChanged;
                ddlProperty.AddCssClass("js-property-dropdown");
                containerControl.Controls.Add(ddlProperty);
            }

            // Clear the list of items.  We will rebuild them to match the selected StepType.
            ddlProperty.Items.Clear();

            // Add an empty option.
            ddlProperty.Items.Add(new ListItem());

            // Add a ListItem for each of the attributes.
            foreach (var entityField in entityFields)
            {
                ddlProperty.Items.Add(new ListItem(entityField.TitleWithoutQualifier, entityField.UniqueName));
            }

            if (stepTypePicker.Page.IsPostBack)
            {
                // If the attribute has been selected, make sure that value is retained.
                ddlProperty.SetValue(stepTypePicker.Page.Request.Params[ddlProperty.UniqueID]);
            }

            // Add the filter controls (comparison type and value).
            foreach (var entityField in entityFields)
            {
                string controlId = string.Format("{0}_{1}", containerControl.ID, entityField.UniqueName);
                if (!containerControl.Controls.OfType <Control>().Any(a => a.ID == controlId))
                {
                    var control = entityField.FieldType.Field.FilterControl(entityField.FieldConfig, controlId, true, filterControl.FilterMode);
                    if (control != null)
                    {
                        containerControl.Controls.Add(control);
                    }
                }
            }
        }
        /// <summary>
        /// Handles the SelectedIndexChanged event of the ddlProperty control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void ddlProperty_SelectedIndexChanged(object sender, EventArgs e)
        {
            var            ddlProperty      = sender as RockDropDownList;
            var            containerControl = ddlProperty.FirstParentControlOfType <DynamicControlsPanel>();
            FilterField    filterControl    = ddlProperty.FirstParentControlOfType <FilterField>();
            StepTypePicker stepTypePicker   = filterControl.ControlsOfTypeRecursive <StepTypePicker>().Where(a => a.HasCssClass("js-step-type-picker")).FirstOrDefault();

            var entityFields = GetStepAttributes(stepTypePicker.SelectedValueAsId());
            var entityField  = entityFields.FirstOrDefault(a => a.UniqueName == ddlProperty.SelectedValue);

            if (entityField != null)
            {
                string controlId = string.Format("{0}_{1}", containerControl.ID, entityField.UniqueName);
                if (!containerControl.Controls.OfType <Control>().Any(a => a.ID == controlId))
                {
                    var control = entityField.FieldType.Field.FilterControl(entityField.FieldConfig, controlId, true, filterControl.FilterMode);
                    if (control != null)
                    {
                        // Add the filter controls of the selected field
                        containerControl.Controls.Add(control);
                    }
                }
            }
        }