Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot add datagrid control #15664

Closed
tchtang opened this issue May 9, 2024 · 22 comments
Closed

Cannot add datagrid control #15664

tchtang opened this issue May 9, 2024 · 22 comments
Labels

Comments

@tchtang
Copy link

tchtang commented May 9, 2024

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

image

To Reproduce

  1. from https://docs.avaloniaui.net/docs/reference/controls/datagrid/

  2. dotnet add package Avalonia.Controls.DataGrid

  3. get compile error
    image
    image

  4. Update patch
    image

become

image

  1. Press F5, cannot run
    image

  2. Have not add datagrid control yet
    image

Expected behavior

No response

Avalonia version

11.1.0-beta2

OS

Windows

Additional context

No response

@tchtang tchtang added the bug label May 9, 2024
@rabbitism
Copy link
Contributor

You need to upgrade to 11.0.10 instead of 11.1beta

@tchtang
Copy link
Author

tchtang commented May 9, 2024

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

nuget also no 11.0.1
image

@rabbitism
Copy link
Contributor

11.0.10

@tchtang
Copy link
Author

tchtang commented May 9, 2024

link please?

@tchtang
Copy link
Author

tchtang commented May 9, 2024

  1. can see welcome message from 11.0.2
    image

  2. from https://www.nuget.org/packages/Avalonia/11.0.10
    dotnet add package Avalonia --version 11.0.10
    image

  3. compile no error, but F5
    image
    whole window only can see title bar

@tchtang
Copy link
Author

tchtang commented May 9, 2024

installed version 11.5 become 11.0.2

image

@rabbitism
Copy link
Contributor

nuget version has nothing to do with extension. just open your csproj file and edit every version related to Avalonia to 11.0.10.

@rabbitism
Copy link
Contributor

rabbitism commented May 9, 2024

And using nuget manager you can choose the version here
image

@tchtang
Copy link
Author

tchtang commented May 9, 2024

thank you your help but still cannot upgrade to 11.0.10
kindly provide link to upgrade all version to 11.0.10

image

image

image

@timunie timunie added question and removed bug labels May 9, 2024
@timunie
Copy link
Contributor

timunie commented May 9, 2024

Please don't open bug reports for questions. Use discussions instead. Will convert this one later when I have time to.

@rabbitism
Copy link
Contributor

rabbitism commented May 9, 2024

When I say every, I mean every. Your desktop, android, ios and browser project is still 11.0.2

@thevortexcloud
Copy link
Contributor

thevortexcloud commented May 9, 2024

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.

@tchtang
Copy link
Author

tchtang commented May 10, 2024

@rabbitism do you see below error?

@tchtang
Copy link
Author

tchtang commented May 10, 2024

@thevortexcloud may i know how to edit project file

@thevortexcloud
Copy link
Contributor

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.

@tchtang
Copy link
Author

tchtang commented May 10, 2024

  • kindly please give me the step, isnt sample as below,

image

  • in .csproj file add all packagereference for below

image

  • that is

image

  • and so on

@thevortexcloud
Copy link
Contributor

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.

@tchtang
Copy link
Author

tchtang commented May 10, 2024

cannot edit .csproj file
image

original .csproj is
image

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.

isnt using
image
developer console?

@hez2010
Copy link
Contributor

hez2010 commented May 10, 2024

In case of android project, you will also need to change the TargetFramework to net7.0-android.

@tchtang
Copy link
Author

tchtang commented May 10, 2024

may i know how to change TargetFramework to net7.0-android.

target framework: 7.0, rebuild solution, error
image

target framework: 6.0, rebuild solution, error
image

@thevortexcloud
Copy link
Contributor

thevortexcloud commented May 10, 2024

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.

@workgroupengineering
Copy link
Contributor

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

@AvaloniaUI AvaloniaUI locked and limited conversation to collaborators May 10, 2024
@MikeCodesDotNET MikeCodesDotNET converted this issue into discussion #15672 May 10, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Projects
None yet
Development

No branches or pull requests

6 participants