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

InvalidOperationException - simple scenario

2 Answers 47 Views
DataFilter
This is a migrated thread and some comments may be shown as answers.
Vasile
Top achievements
Rank 1
Vasile asked on 13 Mar 2011, 01:00 PM
Hello

I try to use RadDataFilter control in my application, and I get and exception whenever I change the filtered property. I belived it may be from my application and then I created a separate project where I shrink down the code to the minimum necessary, the error is still reproduced.

System.Windows.Data Error: 'MS.Internal.Data.DynamicValueConverter' converter failed to convert value 'null' (type 'null'); BindingExpression: Path='Operator' DataItem='Name IsEqualTo <Unset> ' (HashCode=61337593); target element is 'Telerik.Windows.Controls.Data.DataFilter.FilterEditor' (Name=''); target property is 'FilterOperator' (type 'Telerik.Windows.Data.FilterOperator').. System.InvalidOperationException: Can't convert type null to type Telerik.Windows.Data.FilterOperator.

 

at MS.Internal.Data.DynamicValueConverter.Convert(Object value, Type targetType, Object parameter, CultureInfo culture)

at System.Windows.Data.BindingExpression.ConvertToTarget(Object value).

How I did it.
When running project (I cannot attach sample) press once "+" button to add a filter criteria.
It will display the first property filter "Name" correctly, no expcetion.
If you select another property it will throw the exception above, in "Release" mode you will not see it, but in debug you will see the error in Output window and depending if stop on exceptions is selected, the program will stop if the error occurs.

The xaml code is just like this 

 

<Grid x:Name="LayoutRoot" Background="White">
<telerik:RadDataFilter Name="filter1" AutoGenerateItemPropertyDefinitions="True" Source="{Binding}">
</telerik:RadDataFilter>
</Grid 

 

 

 

and in code behind I have

 

public partial class MainPage : UserControl
    {
        public class Record
        {
            public string Name { get; set; }
            public int Id { get; set; }
        }

 

        public ObservableCollection<Record> Records = new ObservableCollection<Record>();

 

        public MainPage()
        {
            InitializeComponent();

 

            #region Create Sample records
            Records.Add(new Record()
            {
                Name = "U1",
                Id = 1
            });
            Records.Add(new Record()
            {
                Name = "U2",
                Id = 2
            });
            Records.Add(new Record()
            {
                Name = "U3",
                Id = 3
            });
            Records.Add(new Record()
            {
                Name = "U4",
                Id = 4
            });
            #endregion

 

            filter1.DataContext = Records;
        }
    }

 

2 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 14 Mar 2011, 02:31 PM
Hi Vasile,

You should not worry about this exception, since it is expected and is handled internally.

Nevertheless, we will add an IValueConverter to the Binding so that you are not getting this exception in the Output Window any more.

The fix will make it for one of the next Latest Internal Build's.

I hope this helps.

All the best,
Ross
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Vasile
Top achievements
Rank 1
answered on 16 Mar 2011, 09:45 PM
Hello Ross,

Glad to hear that you are going to improve this.

Thank you
Vasile
Tags
DataFilter
Asked by
Vasile
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Vasile
Top achievements
Rank 1
Share this question
or