0

My xaml page includes some resources:

<Page.Resources>
    <cnv:FormattingConverter x:Key="formatter" />
    <!-- create an instance of our DataProvider class -->
    <ObjectDataProvider x:Key="ObjOne" ObjectType="{x:Type local:ObjOneDataProvider}"/>
    <!-- define the method which is invoked to obtain our data -->
    <ObjectDataProvider x:Key="ObjTwo" ObjectInstance="{StaticResource ObjOne}" sMethodName="GetAllData"/>
</Page.Resources>

But when I try to open the page in visual studio in preview mode I get the following error:

Error 57 Invalid argument

and the error is cause by the instruction: ObjectInstance="{StaticResource ObjOne}"

Someone know why it occurs?

NOTE: I found that error is caused by the assign of propriety MethodName and not by the ObjectInstance="{StaticResource ObjOne}"

Alessandro
  • 55
  • 1
  • 7

1 Answers1

0

If you want to bind to a method follow the documentation: How to: Bind to a Method

<Page.Resources>
    <cnv:FormattingConverter x:Key="formatter" />

    <ObjectDataProvider x:Key="ObjOne" ObjectType="{x:Type local:ObjOneDataProvider}" MethodName="GetAllData" />
</Page.Resources>
ShadeOfGrey
  • 1,256
  • 12
  • 14