应用运行时未显示Avalonia UI for Linux中的DataGrid [英] DataGrid in Avalonia UI for Linux does not show up when app is running

查看:820
本文介绍了应用运行时未显示Avalonia UI for Linux中的DataGrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在.NET Core for Linux(Fedora)上运行Avalonia UI。
我已遵循本教程对于DataGrid,但老实说,我使用以下命令添加了该包,而不是手动更新 .csproj

I'm running Avalonia UI on .NET Core for Linux (Fedora). I've followed this tutorial for the DataGrid, but honestly I've added the package with the following command, instead of manually updating the .csproj.

dotnet add package Avalonia.Controls.DataGrid

dotnet恢复 dotnet运行之后,我看不到任何DataGrid。
反正xaml

After a dotnet restore and a dotnet run, I can't see any DataGrid. Anyway xaml

<StackPanel>
    <DataGrid AutoGenerateColumns="True" Items="{Binding People}"/>
</StackPanel>

和ViewModel看起来不错。

and ViewModel look fine.

    public ObservableCollection<Person> People { get; }

    public MainWindowViewModel()
    {
        People = new ObservableCollection<Person>(GenerateMockPeopleTable());
    }

我如何找到问题所在?

推荐答案

我忘了在App.xaml中应用 DataGrid 样式(因为我习惯于Windows中的WPF,其中 DataGrid 是标准控件):

I forgot to apply the DataGrid style in the App.xaml (because I'm used to WPF in Windows where the DataGrid is a standard Control):

    <StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Default.xaml"/>

教程清楚地说明了这一步,因此,总之,我只更改了将包添加到项目中的方式,只是为了获取最新版本的

The tutorial clearly states this step, so in conclusion I only changed the way to add the package in the project, just to get last version of the package reference.

  <ItemGroup>
    <PackageReference Include="Avalonia" Version="0.9.9" />
    <PackageReference Include="Avalonia.Controls.DataGrid" Version="0.9.9" />
    <PackageReference Include="Avalonia.Desktop" Version="0.9.9" />
    <PackageReference Include="Avalonia.ReactiveUI" Version="0.9.9" />
  </ItemGroup>

除了版本号(随时间而变化),我可以确认在上面说的教程。

Aside for the version number, which obvioulsy changes with time, I can confirm that all is perfect in the above said tutorial.

这篇关于应用运行时未显示Avalonia UI for Linux中的DataGrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆