가 ** 업데이트가 내 WPF 응용 프로그램에서 데이터 그리드를 사용하는 것을 시도하고있다데이터 그리드 WPF
아래 질문을 참조하십시오하지만 난 참을 수 성능을 발견하고 성능 (사용자 정의 그리드 컨트롤)를 렌더링합니다.
나는 100 행 15 열 및 모든 종류의 스크롤링 또는 심지어 열 너비 조정 페인트를 너무 천천히 사용하여 데이터 세트에 바인딩합니다.
셀 테두리가 켜졌을 때 이전 winforms datagridview의 성능이 좋지 않지만 wpf 카운터 파트에서 눈금 선을 끄면 아무 효과가 없습니다.
그리드가있는 창 :
<Window x:Class="GridPerformanceTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<DataGrid ItemsSource="{Binding}" AutoGenerateColumns="True" EnableColumnVirtualization="True" EnableRowVirtualization="True"
VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling" Background="{x:Null}"
BorderBrush="{x:Null}" IsSynchronizedWithCurrentItem="False" BorderThickness="0" RowHeight="15"
GridLinesVisibility="None" HorizontalGridLinesBrush="{x:Null}" VerticalGridLinesBrush="{x:Null}" ColumnHeaderHeight="15"/>
</Grid>
내 데이터를 채우는 오전 방법 :
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
DataSource source = new DataSource();
DataSet ds = new DataSet();
ds.Tables.Add(source.Execute("select * from tbl_users"));
this.DataContext = ds.Tables[0];
}
}
편집 : 내가 함께 운이 없었다 때문에 그래서
DataGrid에는 당장 찾고있는 것보다 더 많은 기능이 있습니다 (단순히 일반 표시 텍스트 및 복사/붙여 넣기를위한 데이터 선택) 나는 스스로 시도하고 작업하기로 결정했습니다.
이것은 맞춤형 사용자 컨트롤에서의 첫 번째 샷이 될 것이지만 성능이 좋지 않은 소스 인 그리드를 이미 발견했습니다.
내 행 데이터가 포함 된 내 열 및 스택 패널에 대해 눈금 선 분리기를 사용하여 컨트롤을 작성하는 경우 행을 스크롤하는 것이 완벽합니다. 이전의 좋은 winforms 데이터 격자를 사용하는 것과 같습니다.
Grid 컨트롤 코드 :
public partial class CustomGridControl : UserControl
{
public CustomGridControl()
{
InitializeComponent();
for (int i = 0; i < 20; i++)
{
ColumnDefinition col = new ColumnDefinition();
col.Width = new GridLength(75);
_rootGrid.ColumnDefinitions.Add(col);
StackPanel pnl = new StackPanel();
pnl.Orientation = Orientation.Vertical;
for (int x = 0; x < 1000; x++)
{
TextBlock blk = new TextBlock();
blk.Foreground = Brushes.Black;
blk.Text = "Row: " + x.ToString() + " Col: " + i.ToString();
pnl.Children.Add(blk);
}
Grid.SetColumn(pnl, i);
_rootGrid.Children.Add(pnl);
GridSplitter splitter = new GridSplitter();
splitter.Width = 2;
splitter.BorderBrush = Brushes.Black;
Grid.SetColumn(splitter, i);
Grid.SetRowSpan(splitter, 1000);
_rootGrid.Children.Add(splitter);
}
}
그리고 XAML :
<UserControl x:Class="CustomGrid.CustomGridControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid >
<ScrollViewer>
<Grid x:Name="_rootGrid" Background="Aqua"/>
</ScrollViewer>
</Grid>
나는 시도하고 스플리터 중 하나 드래그 성능 그냥 표준으로, 무섭다 WPF DataGrid.
이제는 성능이나 기타 사항을 최적화하기 위해 가상화를 수행하지 않고 있지만 스택 패널을 사용한 성능은 여전히 100 배 우수합니다.
내 질문을 업데이트하려면 - 다른 패널 유형의 열을 처리하는 방법에 대한 아이디어가 있다면 그 열에 대해 동일한 그리드 쪼개기 유형 기능을 사용할 수 있는지 알고 싶습니다.
맞춤 패널/그리드에 대한 좋은 링크도 많은 도움이 될 것입니다.
무엇이 질문입니까? Microsoft DataGrid의 속도를 높일 방법이 없습니다. 좋은 대안이 무엇인지 묻고 있습니까? –
글쎄, 나는 실제로 DataGrid의 속도를 높이기를 원했다 : p 무엇이 좋은 선택 일까? 나는 gridview를 사용해 보았는데 성능이 약간 더 좋았습니다. 좋은 Win olform의 datagridview와 비교할 때 이러한 컨트롤이 사실상 사용할 수 없으므로 뭔가 또는 일부 설정이 잘못된 것처럼 느낍니다. – ChandlerPelhams
Microsoft DataGrid 속도를 높이는 방법이 없습니다. 엑시드는 다른 몇몇 회사와 마찬가지로 훨씬 빠릅니다. 데이터를 쓰지 않아도된다면, ListView/GridView는 훨씬 빠릅니다 (10-20 회). –