func 不是有效的 Windows 运行时参数类型 (win 8.1)

本文关键字:string 类型 参数 win 运行时 bool func 有效 Windows | 更新日期: 2023-09-27 18:32:30

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。

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)

我该怎么办?

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

不要将文件添加到 WindowsRuntimeComponent 项目中,而是将其添加到 Windows 应用商店类库(如果已创建项目,则可以在项目属性->输出类型)中将输出类型更改为类库)。
问题是,如果您创建WindowsRuntime 组件,则可以公开的内容会受到更多限制,因为您公开的所有内容都需要具有有效的WindowsRuntime 类型映射。