Avalonia 无法解析命名空间

发布于 2025-01-12 23:42:45 字数 1004 浏览 3 评论 0原文

所以我正在使用 Avalonia,并且需要为特定类型编写 DataTemplate。但是当我将 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.

这是我需要访问命名空间的地方:

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

以及我如何声明 srv 变量(或者无论你如何称呼它 idk,我不是术语专家)

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

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

是的,它们是一个名称空间,其中 FileTabItem 作为类在其中。

So I was using Avalonia, and needed to write a DataTemplate for a specific type. But when I set the DataType to the required type and run it, it throws this error.

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)

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

Complete xaml file: https://paste.myst.rs/1eoeh40t

And yes, their is a namespace with FileTabItem as a class in it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

欢烬 2025-01-19 23:42:45

Avalonia 还支持 Xamarin Forms 风格的命名空间“using:”语法,它会更努力地为您找到命名空间...

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

到目前为止,我找到的唯一文档位于功能拉取请求中:
功能:替代“using:”语法将命名空间包含到 XAML 文件

Avalonia also supports a Xamarin Forms style "using:" syntax for namespaces that tries harder to find namespaces for you...

<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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文