This is a migrated thread and some comments may be shown as answers.

Cannot cast StringFilterEditor to RadComboBox

3 Answers 89 Views
DataFilter
This is a migrated thread and some comments may be shown as answers.
Austin
Top achievements
Rank 1
Austin asked on 09 Nov 2011, 08:40 PM
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?

3 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 10 Nov 2011, 08:54 AM
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 >>

0
Austin
Top achievements
Rank 1
answered on 10 Nov 2011, 05:19 PM
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;
        }
    }
}
0
Austin
Top achievements
Rank 1
answered on 10 Nov 2011, 11:25 PM
You were right. I wasn't properly naming my EditorTemplateRules and it thus wasn't fetching the appropriate DataTemplate.
Tags
DataFilter
Asked by
Austin
Top achievements
Rank 1
Answers by
Nick
Telerik team
Austin
Top achievements
Rank 1
Share this question
or