C# XAML窗体:在XAML中使用自定义呈现程序中的控件
我在Xamarin中创建了自己的自定义渲染器,如下所示:C# XAML窗体:在XAML中使用自定义呈现程序中的控件,c#,xaml,xamarin,xamarin.forms,custom-renderer,C#,Xaml,Xamarin,Xamarin.forms,Custom Renderer,我在Xamarin中创建了自己的自定义渲染器,如下所示: namespace TestApp { public class CustomEntry : Entry { public CustomEntry () { } } } 如何将其包含在我的HomePage.xaml文件中?我试过这个: <?xml version="1.0" encoding="UTF-8"?> <ContentPage xmlns
namespace TestApp
{
public class CustomEntry : Entry
{
public CustomEntry ()
{
}
}
}
如何将其包含在我的HomePage.xaml文件中?我试过这个:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:TestApp;assembly:TestApp"
x:Class="TestApp.SubPage">
<ContentPage.Content>
<StackLayout>
<local:CustomEntry></local:CustomEntry>
</StackLayout>
</ContentPage.Content>
</ContentPage>
但它不起作用,说CustomEntry不是“”命名空间中的有效控件。有什么想法吗?试着把
改成
和
进入
不管怎样,我发现了问题。看来我的xmlns:local声明是错误的。我有这个:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:TestApp;assembly:TestApp"
x:Class="TestApp.SubPage">
是这样的:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:TestApp;assembly=TestApp"
x:Class="TestApp.SubPage">
似乎为程序集分配了“=”运算符,而不是“:”运算符。上课没变,现在一切都正常了 完成后,我收到一个错误,提示“System.ArgumentNullException:参数不能为null。参数名称:AssemblyName”。仍在试图找出原因。更新了我的代码示例