Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# XAML窗体:在XAML中使用自定义呈现程序中的控件_C#_Xaml_Xamarin_Xamarin.forms_Custom Renderer - Fatal编程技术网

C# XAML窗体:在XAML中使用自定义呈现程序中的控件

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

我在Xamarin中创建了自己的自定义渲染器,如下所示:

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”。仍在试图找出原因。更新了我的代码示例