Cannot cast StringFilterEditor to RadComboBox

4 posts, 0 answers
  1. Austin
    Austin avatar
    10 posts
    Member since:
    Jan 2011

    Posted 09 Nov 2011 Link to this post

    I'm trying to execute the example here: http://www.telerik.com/help/wpf/raddatafilter-how-to-create-custom-filter-editors.html

    When I'm inside the EditorCreated triggered method, switching through the property names I try to set the value of e.Editor to a RadComboBox. See below.

    private void DataFilter_EditorCreated(object sender, Telerik.Windows.Controls.Data.DataFilter.EditorCreatedEventArgs e)
            {
                switch (e.ItemPropertyDefinition.PropertyName)
                {
                    case "Name":
                        RadComboBox temp = (RadComboBox)e.Editor;
                        temp.ItemsSource = nameList;
                        break;
                }
            }

    I get an InvalidCastException when I try to cast e.Editor. It is of type StringFIlterEditor. What am I missing from the example?
  2. Nick
    Admin
    Nick avatar
    593 posts

    Posted 10 Nov 2011 Link to this post

    Hello Austin,

    Are you sure that you have set the DataTemplate property on the EditorTemplateRule to a RadComboBox?
    It would be really helpful if you could send me a sample project so I can look into it.

    Greetings,
    Nikolay Vasilev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Austin
    Austin avatar
    10 posts
    Member since:
    Jan 2011

    Posted 10 Nov 2011 Link to this post

    It's a little difficult for me to throw together a project right now. I hope looking at my EditorTemplateRule is helpful. I know that I'm just using the one straight from the example, I'm definitely not setting anything in it to RadComboBox.

    public class EditorTemplateRule
    {
        private string propertyName;
        private DataTemplate dataTemplate;
     
        /// <summary>
        /// Gets or sets the name of the property.
        /// </summary>
        /// <value>The name of the property.</value>
        public string PropertyName
        {
            get
            {
                return this.propertyName;
            }
            set
            {
                this.propertyName = value;
            }
        }
     
        /// <summary>
        /// Gets or sets the data template.
        /// </summary>
        /// <value>The data template.</value>
        public DataTemplate DataTemplate
        {
            get
            {
                return this.dataTemplate;
            }
            set
            {
                this.dataTemplate = value;
            }
        }
    }
  5. Austin
    Austin avatar
    10 posts
    Member since:
    Jan 2011

    Posted 10 Nov 2011 Link to this post

    You were right. I wasn't properly naming my EditorTemplateRules and it thus wasn't fetching the appropriate DataTemplate.
Back to Top