Cannot add datagrid control
tchtang opened this issue · comments
Describe the bug
I create new project, run in desktop can open window with message 'Welcome to Avalonia'
Want to add datagrid, but cannot do so
To Reproduce
-
from https://docs.avaloniaui.net/docs/reference/controls/datagrid/
-
dotnet add package Avalonia.Controls.DataGrid
become
Expected behavior
No response
Avalonia version
11.1.0-beta2
OS
Windows
Additional context
No response
You need to upgrade to 11.0.10 instead of 11.1beta
version was 11.0.2
after done step 2, has compile error
cannot find version 11.0.1
installed from https://marketplace.visualstudio.com/items?itemName=AvaloniaTeam.AvaloniaVS
11.0.10
link please?
-
from https://www.nuget.org/packages/Avalonia/11.0.10
dotnet add package Avalonia --version 11.0.10
-
compile no error, but F5
whole window only can see title bar
nuget version has nothing to do with extension. just open your csproj file and edit every version related to Avalonia to 11.0.10.
Please don't open bug reports for questions. Use discussions instead. Will convert this one later when I have time to.
When I say every, I mean every. Your desktop, android, ios and browser project is still 11.0.2
Also the VS package manager is a real pain to use with a large dependency chain like Avalonia (it often complains about transient conflicts which forces you to upgrade things in a specific order). It's easier to just manually upgrade everything by editing your project file. You should be able to upgrade all packages fairly easily though by checking the box on the updates tab.
@rabbitism do you see below error?
@thevortexcloud may i know how to edit project file
If you are using a project using the new SDK format (which you likely are if you have made a new project), you can double click the project in the solution explorer. If you are using the old format, you need to unload the project and then right click it, and press edit. Or you can just open it directly with an external text editor.
You may also need to trigger a restore. Try running dotnet restore
in a terminal while inside your project directory. While you are there, also run dotnet new update
to update your Avalonia templates. If it still does not work after all that, then you should be able to create a new solution using the latest templates.
You may also need to trigger a restore. Try running dotnet restore in a terminal while inside your project directory. While you are there, also run dotnet new update to update your Avalonia templates. If it still does not work after all that, then you should be able to create a new solution using the latest templates.
In case of android project, you will also need to change the TargetFramework to net7.0-android.
I suggest reading the official .NET docs and watching/reading a few tutorials. Most of this has nothing directly to do with Avalonia.
https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview
https://learn.microsoft.com/en-us/dotnet/standard/frameworks
Anyway, you should not have android/iOS package references in a project that does not target the correct TFM.
You have mixed Desktop, iOS and Android package. Single project is experimetal feature.
You should use following comnand to create new Cross platform project from template
dotnet new avalonia.xplat -n MyApp
or select Cross Platform Application
template.
After creation. You have more project, each for plat (MyApp.Android.cspoj, ...).
The Cross plat xaml and code should put into MyApp.csproj
Add DataGrid package to MyApp.csproj
Rebuild the solution
Edit app.axaml
and add DataGrid Style