Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4081170
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:01:33+00:00 2026-05-20T18:01:33+00:00

I’m dealing with a problem in WPF binding. I’m creating a user control which

  • 0

I’m dealing with a problem in WPF binding.
I’m creating a user control which present a datagrid, fiiltered by 2 possible values.
The first value is set by a textbox, the second one by a combo box.
I’m using an ObjectDataProvider to map a methos with 2 parameters, and the textbox and the combobox should set these 2 parameters.
Here’s the code.

<UserControl x:Class="VisualHorse.Corse"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:local="clr-namespace:VisualHorse"
         xmlns:system="clr-namespace:System;assembly=mscorlib"
         mc:Ignorable="d" 
         d:DesignHeight="300" d:DesignWidth="530" Loaded="UserControl_Loaded">
<UserControl.Resources>
    <ObjectDataProvider x:Key="HorseDataProvider"
             ObjectType="{x:Type local:HorseDataProvider}"
             MethodName="GetCorse" >
        <ObjectDataProvider.MethodParameters>
            <x:Static Member="system:String.Empty" />
            <x:Static Member="system:String.Empty" />
        </ObjectDataProvider.MethodParameters>
    </ObjectDataProvider>
</UserControl.Resources>
<StackPanel >
    <Grid  Name="GRIDFilter" Height="50">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Label Content="Data corsa" HorizontalAlignment="Center" Name="label1" VerticalAlignment="Center" />
        <Label Content="Località" Grid.Column="1" HorizontalAlignment="Center" Name="label2" VerticalAlignment="Center" />
        <Label Content="N° Corsa" Grid.Column="2" HorizontalAlignment="Center" Name="label3" VerticalAlignment="Center" />
        <Button Content="Filtra" Grid.Column="3" Grid.RowSpan="2" Width="50" Height="30" />
        <DatePicker Grid.Row="1"  HorizontalAlignment="Center" Name="DPDataCorsa" VerticalAlignment="Center" Width="115" />
        <ComboBox Grid.Column="1" Grid.Row="1"  HorizontalAlignment="Stretch" Name="CBlocalita" VerticalAlignment="Center" Margin="5,0" >
            <ComboBox.SelectedValue>
                <Binding Source="{StaticResource HorseDataProvider}"
                 Path="MethodParameters[0]"
                 BindsDirectlyToSource="true"/>
            </ComboBox.SelectedValue>
        </ComboBox>
        <TextBox Name="TBNumCorsa" Grid.Column="2" Grid.Row="1" Margin="5,0" >
            <Binding Source="{StaticResource HorseDataProvider}"
                 Path="MethodParameters[1]"
                 BindsDirectlyToSource="true"
                 UpdateSourceTrigger="PropertyChanged" />
        </TextBox>
    </Grid>

    <DataGrid Name="DGCorse" ItemsSource="{Binding Source={StaticResource HorseDataProvider}}" AutoGenerateColumns="False" Margin="0,10,0,0" CanUserResizeRows="False" SelectionMode="Single">
        <DataGrid.Columns>
            <DataGridTextColumn Binding="{Binding Path=Localita.descrizione}" Header="Località" />
            <DataGridTextColumn Binding="{Binding Path=data, StringFormat=\{0:d\}}" Header="Data Corsa" />
            <DataGridTextColumn Binding="{Binding Path=numero}" Header="N° Corsa" />
            <DataGridTextColumn Binding="{Binding Path=TipoCorsa.descrizione}" Header="Tipo corsa" />
            <DataGridTextColumn Binding="{Binding Path=TipoTerreno.descrizione}" Header="Terreno" />
            <DataGridTextColumn Binding="{Binding Path=TipoFantino.descrizione}" Header="Tipo fantino" />
            <DataGridTextColumn Binding="{Binding Path=premio, StringFormat=\{0:c\}}" Header="Premio" />
            <DataGridTextColumn Binding="{Binding Path=distacchi}" Header="Distacchi" />
            <DataGridTextColumn Binding="{Binding Path=distanza}" Header="Distanza" />
            <DataGridTextColumn Binding="{Binding Path=TipoPista.descrizione}" Header="Pista" />
            <DataGridTextColumn Binding="{Binding Path=Eta.descrizione}" Header="Età" />
        </DataGrid.Columns>
    </DataGrid>
</StackPanel>

What’s wrong with it?
Everything works fine if I just bind the textbox property, but trying to bind the Combobox.SeletedValue property to the first method parameter it throws an exception (silently handled by the wpf engine):

System.Windows.Data Error: 35 :
ObjectDataProvider: Failure trying to
invoke method on type;
Method=’GetCorse’;
Type=’HorseDataProvider’; Error=’No
method was found with matching
parameter signature.’
MissingMethodException:’System.MissingMethodException:
Method
‘VisualHorse.HorseDataProvider.GetCorse’
not found. at
System.RuntimeType.InvokeMember(String
name, BindingFlags bindingFlags,
Binder binder, Object target, Object[]
providedArgs, ParameterModifier[]
modifiers, CultureInfo culture,
String[] namedParams) at
System.Windows.Data.ObjectDataProvider.InvokeMethodOnInstance(Exception&
e)’

Any help would be appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:01:34+00:00Added an answer on May 20, 2026 at 6:01 pm

    Ok, I found the issue on my approach.
    Simply, I didn’t get that the ComboBox.SelectedValue type depends on how I populate the combobox (wich I did in code behind).
    Simply modifying the ObjectDataProvider definition in the following way, resolved the problem:

    <ObjectDataProvider x:Key="HorseDataProvider"
                 ObjectType="{x:Type local:HorseDataProvider}"
                 MethodName="GetCorse" >
            <ObjectDataProvider.MethodParameters>                
                <system:Int32>0</system:Int32>
                <x:Static Member="system:String.Empty" />                 
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
    

    This way the ComboBox.SelectedItem is bound to an Int32 method parameter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker
I need to clean up various Word 'smart' characters in user input, including but
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.