应用程序运行时,Linux 版 Avalonia UI 中的 DataGrid 不显示 [英] DataGrid in Avalonia UI for Linux does not show up when app is running
问题描述
我正在 .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 restore
和 dotnet run
之后,我看不到任何 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());
}
我怎样才能找到问题所在?
How can I find what is going wrong?
推荐答案
我忘记在 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.
这篇关于应用程序运行时,Linux 版 Avalonia UI 中的 DataGrid 不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!