2012-01-17 26 views
0
造成

我的XAML頁面包括一些資源:預覽頁面錯誤由無效的參數在Page.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> 

但是當我嘗試打開在預覽模式下Visual Studio中的頁面我得到以下錯誤:

Error 57 Invalid argument

和錯誤原因是由指令: ObjectInstance = 「{StaticResource的ObjOne}」

有人知道它爲什麼會發生?

注:我發現,錯誤是由禮methodName的分配,而不是由ObjectInstance =「{StaticResource的ObjOne}」引發

回答

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>