简体   繁体   English

Avalonia 无法解析名称空间

[英]Avalonia is unable to resolve a namespace

So I was using Avalonia, and needed to write a DataTemplate for a specific type.所以我使用的是 Avalonia,需要为特定类型编写一个 DataTemplate。 But when I set the DataType to the required type and run it, it throws this error.但是当我将 DataType 设置为所需的类型并运行它时,它会抛出此错误。

D:\Some\Random\Path\Tachyon\src/App.axaml(9,23,9,23): Avalonia error XAMLIL:
Unable to resolve type FileTabItem from namespace https://github.com/avaloniaui Line 9, position 23. [D:\Some\Random\Path\Tachyon\Tachyon.csproj]
The build failed. Fix the build errors and run again.

This is where I need to access the namespace:这是我需要访问命名空间的地方:

<TabControl>
    <TabControl.ContentTemplate>
        <DataTemplate DataType="srv:FileTabItem">
            <TextBlock Text="{Binding Content}"/>
        </DataTemplate>
    </TabControl.ContentTemplate>
</TabControl>

and how I've declared the srv variable(or whatever u call it idk I'm no expert in terminology)以及我是如何声明srv变量的(或者你怎么称呼它 idk 我不是术语专家)

<Window xmlns:srv="clr-namespace:Tachyon.Services">

Complete xaml file: https://paste.myst.rs/1eoeh40t完整的xaml文件: https://paste.myst.rs/1eoeh40t

And yes, their is a namespace with FileTabItem as a class in it.是的,它们是一个名称空间,其中 FileTabItem 为 class。

Avalonia also supports a Xamarin Forms style "using:" syntax for namespaces that tries harder to find namespaces for you... Avalonia 还支持 Xamarin Forms 风格的命名空间“使用:”语法,它会更努力地为您找到命名空间......

<Window xmlns="https://github.com/avaloniaui"
        xmlns:srv="using:Tachyon.Services">

The only documentation I've found so far is in the features pull request:到目前为止我发现的唯一文档是在功能拉取请求中:
Feature: alternative "using:" syntax to include namespace to XAML file功能:替代“使用:”语法将命名空间包含到 XAML 文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM