[Avalonia] Beginner attempting a spreadsheet application. Having issues displaying rows.
I'm really hoping that someone with some experience may have some time to assist me. This is my first time creating a UI of any kind as well as utilizing the MVVM development pattern, so I'm very out of my element. I am having issues with displaying rows of a DataGrid. If you are available, please reach out with a time/place and my desperate self will be there! Thank you!
15 Replies
What issue are you hitting specifically? Asking specific questions or sharing code would be helpful
$code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
For longer snippets, use: https://paste.mod.gg/The issue is more so that I really am not sure what I am looking for to be wrong. I am using a somewhat substantial amount of prewritten code as this is for a school assignment, but I cannot seem to figure out how to make it work properly.
I apologize for the delayed responce
U dont need to apologize but if u dont provide the code there is not much we can do to help u, that is what he meant with the above.
BlazeBin - iebbaafbnjja
A tool for sharing your source code with the world!
Took a bit to figure it out lol
Currently, when run, it displays only the row of column headers
It is pretty messy and imcomplete at the moment. Have been attemping to see if the commented function InitializeSpreadsheet in MainWindowViewModel might help as it was another provided function, but it dosen't correlate with the code I have currently quite yet
well I dont know about reactiveui so not sure I will be able to help you but I will take a look
Avalonia have reactiveui and communitytoolkit and I normally use the later
I'm not all to familiar with the uses of Observers and Event handling quite yet, would you say it might be more documented or beginner friendly? Or just same thing different platform?
well those are mainly boiletplate of code that enable the code behind and the UI to syncronize and update on changes
for example in community toolkit
Really is
Where the viewmodel class usually inherits from INotifyPropertyChanged
so there is a bit more code then just that behind the scenes that connects things up
@JonahJ ok so I will try to go thru the basics for now, you're using ReactiveUI with Avalonia, so you do not need to do things like this in your code
and
and
and
and
since you're using ReactiveUI you by default already have these kind of things all done for u
and all u really need to do is for example
AvaloniaUI also requires u to setup an additional entry in order for the DataGrid to show up in your App.axaml file
you need to add inside of
<Application.Styles>
not sure if u did thatI do have that included within my App.axaml
then I would suggest you to start simpler so you get to understand how the DataGrid works first, meaning u can delete the Spreadsheet.cs, Cell.cs
and restore your file MainWindowViewModel to
so an example of binding data to your DataGrid would be
So imagine we have a model like such
In your MainWindowViewModel you would then create the following collection
In your axaml you would bind
and inside of your constructor
MainWindowViewModel
we can fill in some data as test
assuming its all good and you run your app u should see something similar to this
Let me know if u have any questions up to this point