WPF -DataGrid extrem langsam scrollenC#

Ein Treffpunkt für C#-Programmierer
Anonymous
 WPF -DataGrid extrem langsam scrollen

Post by Anonymous »

Ich muss in meiner WPF -App eine Tabellenkalkulationssteuerung implementieren, und alle meine Versuche, das WPF -DataGrid zu verwenden, haben zu sehr schlechten Scrollen geführt (es ist in horizontaler als vertikal schlechter als vertikal). />
[*]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));
}
}
}
}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post
  • WPF DataGrid Virtualization – Seltsamer Fehler nach dem Scrollen
    by Guest » » in C#
    0 Replies
    11 Views
    Last post by Guest
  • MoviePy write_videofile ist extrem langsam
    by Anonymous » » in Python
    0 Replies
    7 Views
    Last post by Anonymous
  • WSL2 ist beim Erstellen extrem langsam
    by Guest » » in C++
    0 Replies
    2 Views
    Last post by Guest
  • WSL2 ist beim Erstellen extrem langsam
    by Guest » » in C++
    0 Replies
    3 Views
    Last post by Guest
  • WSL2 beim Erstellen extrem langsam [geschlossen]
    by Guest » » in C++
    0 Replies
    3 Views
    Last post by Guest