我的xaml页面包含一些资源:
<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>
但是当我尝试在预览模式下在visual studio中打开页面时,我收到以下错误:
错误57参数无效
错误是由指令引起的: ObjectInstance =“{StaticResource ObjOne}”
有人知道它为什么会发生吗?
注意:我发现错误是由适当的MethodName分配引起的,而不是由ObjectInstance =“{StaticResource ObjOne}”
引起的答案 0 :(得分:0)
如果要绑定到方法,请遵循以下文档: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>