如何在Xamarin Forms中添加多个名称空间?

时间:2017-09-28 17:47:30

标签: xml xamarin xamarin.forms

我遇到需要在单个内容页面中使用两个自定义控件的情况。但是当我尝试添加这两个控件的名称空间时,我得到一个例外。对此有什么解决方案吗?

<ContentPage Title="Settings" xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:controls="clr-namespace:Naseej.Control, clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin.Abstractions" x:Class="Naseej.Page.Setting.SettingList">

2 个答案:

答案 0 :(得分:2)

试试这个:

<ContentPage Title="Settings" xmlns="http://xamarin.com/schemas/2014/forms" 
 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
 xmlns:controls="clr-namespace:Naseej.Control, clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin.Abstractions"
 xmlns:anotherControls="Your.Assembly.Path"
 x:Class="Naseej.Page.Setting.SettingList">

答案 1 :(得分:0)

您可以尝试分离控件

<ContentPage Title="Settings" 
 xmlns="http://xamarin.com/schemas/2014/forms"
 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
 xmlns:control1="clr-namespace:Naseej.Control;assembly=ImageCircle.Forms.Plugin.Abstractions"
 xmlns:control2="clr-namespace:Naseej.Control2;assembly=ImageCircle.Forms.Plugin.Abstractions"
 x:Class="Naseej.Page.Setting.SettingList">