MainWindow.axaml
Код: Выделить всё
Код: Выделить всё
namespace SalesApp.ViewModels;
using System;
using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
public class SalesByDateDto
{
public DateTime Date { get; set; }
public int OrderCount { get; set; }
public decimal TotalRevenue { get; set; }
public int ItemsCount { get; set; }
}
public partial class MainWindowViewModel : ViewModelBase
{
[ObservableProperty]
private ObservableCollection dateSales = new();
public string Greeting { get; } = "Welcome to Avalonia!";
[RelayCommand]
private void LoadData()
{
// Simulate loading data
DateSales = new ObservableCollection
{
new SalesByDateDto { Date = DateTime.Today, OrderCount = 10, TotalRevenue = 1000m, ItemsCount = 50 },
new SalesByDateDto { Date = DateTime.Today.AddDays(-1), OrderCount = 8, TotalRevenue = 800m, ItemsCount = 40 },
new SalesByDateDto { Date = DateTime.Today.AddDays(-2), OrderCount = 12, TotalRevenue = 1200m, ItemsCount = 60 }
};
}
}
Код: Выделить всё
- Версия Avalonia — 11.3.12
- Операционная система — Ubuntu 24.04.4 LTS
Код: Выделить всё
dotnet new avalonia.mvvm -o SalesApp
cd SalesApp
dotnet package update
dotnet package add Avalonia.Controls.DataGrid
Любые отрицательные избиратели, пожалуйста, рассмотрите возможность оставить комментарий. Почему вы понижаете публикацию
Подробнее здесь: https://stackoverflow.com/questions/799 ... a-datagrid
Мобильная версия