[*]Simplified cell styles
[*]Virtualization
[*]Disabling automationpeer
The WinForms DataGridView, however, Es ist sehr langsam bei der Auswahl von Zellen, da die Reihen ungebunden sind und all das, so dass es auch nicht für meinen Zweck verwendet werden kann und ich immer noch sehr ungeschickt werde, auch für ein 100x100 -Gitter. Kontrollen, aber alle haben auch Probleme. Syncfusion braucht beispielsweise viel Zeit, um aus Excel einzufügen, Reprogramm , um zu laden. Am Ende sehe ich dies also nicht gut.
Code: Select all
< /code>
Mainwindow.xaml.cs
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Automation.Peers;
using System.Windows.Controls;
using System.Windows.Data;
namespace WpfApp1
{
public partial class MainWindow : Window
{
public MainWindowViewModel vm
{
get => _vm;
}
private MainWindowViewModel _vm;
public MainWindow()
{
InitializeComponent();
_vm = new MainWindowViewModel();
this.DataContext = _vm;
for (int i = 0; i < vm.Rows[0].Columns.Count; ++i)
{
var Col = new DataGridTextColumn();
var Bind = new Binding();
Bind.Path = new PropertyPath($"Columns[{i}]");
Col.Binding = Bind;
Col.Header = i;
Col.Width = 80;
DG.Columns.Add(Col);
}
}
protected override System.Windows.Automation.Peers.AutomationPeer OnCreateAutomationPeer()
{
return new CustomWindowAutomationPeer(this);
}
public class CustomWindowAutomationPeer : FrameworkElementAutomationPeer
{
public CustomWindowAutomationPeer(FrameworkElement owner) : base(owner) { }
protected override string GetNameCore()
{
return "CustomWindowAutomationPeer";
}
protected override AutomationControlType GetAutomationControlTypeCore()
{
return AutomationControlType.Window;
}
protected override List GetChildrenCore()
{
return new List();
}
}
}
public class ObservableObject : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string name = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
}
public class MainWindowViewModel : ObservableObject
{
public class RowData
{
public ObservableCollection Columns
{
get => _Columns;
}
private ObservableCollection _Columns;
public RowData(int iStart)
{
var NumCols = 101;
_Columns = new ObservableCollection(Enumerable.Range(iStart, NumCols).Select(i => Convert.ToDouble(i)));
}
}
public ObservableCollection Rows
{
get => _Rows;
}
private ObservableCollection _Rows;
public MainWindowViewModel()
{
_Rows = new ObservableCollection();
var NumRows = 101;
for (int i = 0; i < NumRows; ++i)
{
_Rows.Add(new RowData(i));
}
}
}
}