你会如何在XAML和代码背后引用?似乎 mrkup:Class="System.Web.UI.HtmlTextWriterTag" 在下面的剪辑中会起作用
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ns.proj"
mrkup:Class="System.Web.UI.HtmlTextWriterTag"
>
...
允许以下内容 .
<mrkup:hr/>
我仍然得到未声明的前缀错误 .
我已经尝试将树倒退到System.Web.UI并确保我没有使用像html:xx这样的保留字,但它仍然失败 . 我必须忽视一些基本的或严重缺少XAML / Xamarin.Forms前提的东西 .
Update Edit:
基于Jason和Diego的输入:Intellisense在键入 using xmlns:mrkup="using: 之后踢了一脚
xmlns:mrkup="clr-namespace:System.Web;assembly=netstandard"
这是一个很好的开始
<mrkup:UI.HtmlTextWriterTag hr=""/>
使用mrkup失败:在xmlns clr-Namespace中找不到UI.HtmlTextWriterTag.hr:System.Web; assembly = netstandard
是否有可能.UI不在.NET Standard 2.0的System.Web中?
Update to the Update:
在.NET Standard 2.0的System.Web中,UI似乎是 NOT . 这是来自C:\ Program Files(x86)\ Microsoft SDKs \ NuGetPackagesFallback \ NETStandard.Library \ 2.0.1 \ build \ netstandard2.0 \ ref中的System.Web.dll
1 回答
实际上,您必须在使用之前声明
mrkup
前缀 .像这样:
我'm not sure where the namespace ends, so in the snippet above I'假设命名空间是
System.Web.UI
和类HtmlTextWriterTag
然后你有一个属性hr
. 如果引用的命名空间在实际项目之外,则必须注意声明的assembly
部分,但是在引用同一程序集的类时可以忽略它 .您可以查看official docs from Microsoft about Declaring Namespaces for Types以获取更详细的信息 .