Partial
Partial

Reputation: 9989

DataGridView draw bug in WPF

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?

Upvotes: 1

Views: 1536

Answers (2)

Tim Santeford
Tim Santeford

Reputation: 28121

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).

Upvotes: 3

Steffen Opel
Steffen Opel

Reputation: 64741

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!

Upvotes: 1

Related Questions