0

I keep getting the error: ArgumentException: Object of type 'System.String' cannot be converted to type 'System.Windows.RoutedEventHandler'.

When I try to run an app. The component causing the error is the filter control component I downloaded here. I have successfully used this component for the same type of application before so I don't think it is the component code.

The only difference between the 2 apps I can tell is the wpf page that loads the component sits in a different assembly than the wpf window that loads the page.

Any ideas why this would be happening?

Here's the XAML:

<FCC:FilterControl x:Name="EquipNumFilterBox" Height="25" Header="Filter..." Margin="10,2,0,0" Filter="FilterBox_Filter" ClearFilter="FilterBox_ClearFilter"/>

Here's the code behind:

    private void FilterBox_Filter(object sender, FilterControlComponent.FilterEventArgs e)
    {
        e.IsFilterApplied = true;
        ((CollectionViewSource)this.Resources["theDataView"]).View.Refresh();
    }

    private void FilterBox_ClearFilter(object sender, RoutedEventArgs e)
    {
        ((CollectionViewSource)this.Resources["theDataView"]).View.Refresh();
    }
  • You're somehow giving it a string where a routedeventhandler is expected. In some of the code or markup you haven't posted. – Andy Mar 05 '19 at 09:57
  • Please provide a [MCVE](https://stackoverflow.com/help/mcve) of your issue when asking a question on SO. – mm8 Mar 05 '19 at 14:53
  • I added the XAML and code behind. Nothing special about them. There error pops up when the InitializeComponent(); runs. – Paul Hildebrandt Mar 06 '19 at 04:39

1 Answers1

0

Managed to get around this by assigning the event in the code behind.