WPF 中的 DataGridView 绘制错误

发布于 2024-08-02 16:55:37 字数 756 浏览 4 评论 0 原文

我在 WPF 项目中使用 WindowsFormsIntegration 来添加 DataGridView,但在窗口中绘制它时遇到了一些问题(需要一段时间)。

我知道 的解决方案双缓冲 datagridview 但如何在 WPF 的 XAML 或 WPF 的 C# 中使用它?

WPF 中带有 WindowsFormsIntegration 的双缓冲 datagridview 的示例或任何替代解决方案将非常感激!

感谢您提供的任何帮助!


编辑:

我正在使用 Microsoft Expression Blend 2 作为界面,我注意到它生成了一个资源字典。删除其中的一些样式实际上解决了部分问题,但我不断遇到同样的问题。导致包含 DataGridView 的 GroupBox 可见的操作是:单击选项卡控件,然后选择 RadioButton。一旦选中某个RadioButtion,某个GroupBox 就会变得可见。它包含 WindowsFormsIntegration 主机,该主机本身包含 DataGridView,但 WindowsFormsIntegration 不会出现(或不会绘制),直到我将鼠标放在 GroupBox 内的按钮上... Expression Blend 是否对我的问题负责?

I am using WindowsFormsIntegration in a WPF project to add a DataGridView and I am having some problems with it simply being drawn in the window (it takes a while).

I am aware of the solution with the doublebuffered datagridview but how can you use this in XAML for WPF or in C# for WPF?

An example of the doublebuffered datagridview in WPF with WindowsFormsIntegration or any alternative solution would really be appreciated!!

Thank you for any help provided!


Edit:

I am using Microsoft Expression Blend 2 for the interface and I noticed it generated a Resource Dictionary. Removing some of the styling in there actually solved part of the problem but I keep getting the same problem. The actions that are leading to make the GroupBox that contains the DataGridView to be visible are: clicking on a tab control then choosing a RadioButton. Once a certain RadioButtion is checked, a certain GroupBox becomes visible. It contains the WindowsFormsIntegration host which itself contains the DataGridView but the WindowsFormsIntegration does not appear (or is not drawn) until I take the mouse and put it over a button inside the GroupBox... Is Expression Blend responsible for my problems?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

宛菡 2024-08-09 16:55:37

使用 Windows 窗体集成进行数据网格的一个很好的替代方案是使用 Infragistics 提供的免费且非常棒的原生 WPF 数据网格。他们称之为 xamDataGrid 控件,相信我,它绝对漂亮。将其引入我公司的应用程序中,我得到了一些主要的奖励。

下载页面位于:http://www.infragistics.com /dotnet/netadvantage/wpf.aspx?panel=Downloads#Downloads

概述页面:http://www.infragistics.com/dotnet/netadvantage/wpf/xamdatagrid.aspx#Overview

WPF Express 2009 卷的 NetAdvantage。
1 让您开始
用于 WPF 开发的 xamDataGrid™(此
不是试用版,而是真实的功能
xamDataGrid 版本 9.1;没有购买
有必要在您的
应用程序)。

A great alternative to using windows forms integration for datagrids is using the free and total awesome native WPF datagrid by Infragistics. They call it the xamDataGrid control and it absolutely beautiful believe me. I go some major brownie points for introducing this into my company's app.

Download page is here: http://www.infragistics.com/dotnet/netadvantage/wpf.aspx?panel=Downloads#Downloads

Overview page: http://www.infragistics.com/dotnet/netadvantage/wpf/xamdatagrid.aspx#Overview

NetAdvantage for WPF Express 2009 Vol.
1 gets you started with the
xamDataGrid™ for WPF development (this
is not a trial and features the real
xamDataGrid version 9.1; no purchase
is necessary to use it in your
applications).

七堇年 2024-08-09 16:55:37

我知道解决方案
双缓冲 datagridview 但如何
您可以在 WPF 的 XAML 中使用它吗?
用于 WPF 的 C#?

使用此解决方案没有什么特别之处,除了促进 WPF 应用程序和其他类型的 Microsoft Windows 应用程序(在您的情况下为 Windows 窗体)之间的现有互操作之外。

有关此类主题的第一站应该是 WPF 迁移和互操作性。特别是,您会发现这两种情况的演练(我意识到您已经涵盖了这一点,只是为了完整性):

这些演练基于 MaskedTextBox 类 但您应该能够将其调整为 DataGridView 类 轻松实现。

托管从 DataGridView 派生的自定义类所需的额外步骤(例如 CustomDataGridView)再次在演练中介绍:

此示例是一个复合控件,显然比简单派生的 CustomDataGridView 根据 您想要实现的现有解决方案,但您可以简单地跳过多余的步骤,仍然可以找到有关此自定义控件等的程序集引用的所有元信息。

也就是说,考虑到您的编辑,我认为缺少双缓冲实际上并不是导致问题的,尽管它确实可能会补救效果,因此我暂时将这个实验留给您 - 很好运气!

I am aware of the solution with the
doublebuffered datagridview but how
can you use this in XAML for WPF or in
C# for WPF?

There is nothing special regarding using this solution as is other than facilitating the existing interoperation between WPF applications and other types of Microsoft Windows applications, Windows Forms in your case.

Your first stop regarding topics like this should be WPF Migration and Interoperability. In particular you'll find there walkthroughs for both scenarios (I realize you have this covered already, just for completeness):

These walkthroughs are based on the MaskedTextBox Class but you should be able to adapt this to the DataGridView Class easily.

The additional steps required for hosting a custom class derived from DataGridView instead, say CustomDataGridView, are again covered in a walkthrough:

This example, being a composite control, is obviously more complicated than the simple derived CustomDataGridView as per the existing solution you want to implement, but you can simply skip the superfluous steps and still find all meta information regarding assembly references for this custom control and the like covered.

That said, given your edit I don't think that missing double buffering is actually causing the issue, though it might indeed remedy the effect, hence I'll leave this experiment to you for the moment - good luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文