func <string,string,bool>不是有效的Windows运行时参数类型(win 8.1)</string,string,bool>

时间:2013-09-23 16:07:22

标签: c# windows-8 autocomplete winrt-xaml

https://github.com/igorkulman/AutoCompleteBox/blob/master/AutoCompleteBox/AutoCompleteBox.cs

我下载了这个控件,但我无法构建它,

public Func<string, string, bool> SearchFunction
{
   get { return (Func<string, string, bool>)GetValue(SearchFunctionProperty); }
   set { SetValue(SearchFunctionProperty, value); }
}

当我尝试将SearchFunction用作公共时,我收到此错误。当我将其更改为内部时它正在工作,但这次我无法从我的项目中访问SearchFunction。

Method 'CodeAutoComplete.AutoCompleteBox.SearchFunction.get()' has a parameter of type
 'System.Func<System.String, System.String, System.Boolean>' in its signature. Although 
this generic type is not a valid Windows Runtime type, the type or its generic parameters 
implement interfaces that are valid Windows Runtime types. Consider changing the type 
'System.Func<T1, T2, TResult>' in the method signature. It is not a valid Windows Runtime 
parameter type. C:\\..CodeAutoComplete\AutoCompleteBox.cs CodeAutoComplete (Windows 8.1)

我该怎么办?

1 个答案:

答案 0 :(得分:3)

不是将文件添加到WindowsRuntimeComponent项目,而是将其添加到Windows商店类库(如果您已经创建了项目,则可以在项目属性中将输出类型更改为类库 - >输出类型)。
问题是,如果您创建一个WindowsRuntime组件,那么您可以公开lot more limited,因为您公开的所有内容都需要有一个有效的WindowsRuntime类型映射。

相关问题