views:

34

answers:

0

Continuing from the original question, when the ObjectDataProvider binds from the specified Method, a number of BindingExceptions are raised similar to the following:

System.Windows.Data Error: 39 : BindingExpression path error: 'xxx' property not found on 'object' ''Object' (HashCode=15292788)'. BindingExpression:Path=xxx; DataItem='Object' (HashCode=15292788); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')

The data appears correctly on the UserControl yet these errors are being generated. I'm thinking the problem is occurring because WPF doesn't know the exact type thats being returned when it initially calls the method. I tried setting the ObjectType property of the ObjectDataProvider but it seems you can only set EITHER ObjectInstance or ObjectType but not BOTH.

    <ObjectDataProvider x:Key="oDataForGrid" ObjectInstance="_this.DataContext"
                        MethodName="GetGridContracts" IsAsynchronous="True"  >
        <ObjectDataProvider.MethodParameters>
            <system:Int32>1</system:Int32>
            <system:DateTime>2009-12-12</system:DateTime>
        </ObjectDataProvider.MethodParameters>
    </ObjectDataProvider>
public List<ContractListData> GetGridContracts(Int32 option, DateTime? date)

Again the data is displayed fine but I'd like to do this w/o the exceptions.

Couple of Questions:

  1. Aside from using SupressMessage, is there a way to change the code so the errors do not occur?
  2. Would someone write a couple of lines explaining the "magic" that occurs when the ObjectDataProvider calls the MethodName?