This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi Just wondering what the recommended approach is for styling the column headers within the datagrid (the toggle buttons not just the label), also how can I achieve alternating row colours. I've tried setting it up in the style of the DataGridRow but not having much luck... I'm no doubt missing something obvious on this one! Kevin |
|
|
Any update on these, Do I need to restyle the entire datagrid, I'm assuming the column headers are inside the presenter? I haven't been able to explore too much as Blend seems to bork the style of the datagrid(Columns remain but rows disappear. Any assistance would be appreciated. |
|
|
Hello Customizing the column headers is not so easy, so to help you out I've attached a text file containing the bulk of the code that you need. Copy this code into a resource dictionary that your application uses. Make sure the resource dictionary merges in one of our themes to provide most of the resources that the attached code needs. The attached code is based on OfficeBlue, so one of the Office themes will work best. The bit right at the top of the file is where you'll add your custom column header code. I highly recommend that you look in one of the theme files provided with WPF Elements that ends with .DataGrid. Search for "GridViewColumnHeaderStyle" and follow this style (or copy it) to build your own. This style is responsible for the look of the column headers in all states - a normal column header, the padding displayed at the right of the DataGrid if the columns don't span the width, and also the look of the column headers within the grouping panel. If you use data grid filtering in your application, you'll want to make sure your custom column header includes the filter button. For alternating row colors, simply set the AlternationCount of the DataGrid to 2, and set the AlternatingRowBackground to be the color you want. Let me know if you have questions about any of this. -Jason Fauchelle |
|
|
Yikes slight understatement there mate. I've it done now and working fine. Yeah I stupidly had a rectangle(used for an animated mouse over effect), which was causing me not to see the alternating colours... Cheers Kevin |
|
|
Just a quick note, not sure if this occurs because of my style or a bug when using a DataTable to populate the datagrid but the last column is empty. If the user drags the final column(its empty) a null reference exception is raised. I handled this by collapsing the visibility of the thumb in the event the content of ContentPresenter for the column is null. |
|
|
Hello Kevin I've never come across that issue before. I don't think it would be an issue with the style. Although, if you turn off your style, is the problem still there? If you send me a sample project containing your custom style and the DataTable source, I could look into debugging this and probably prevent the null reference exception within the product. Good that you have some kind of solution though. -Jason Fauchelle |
|