In my WPF project I populate a data grid from a random source (a table in a database), so the number of columns and the column names vary each time the grid is filled. The column names of a table are used as grid headers. During testing I found that every grid header with underscore characters always has the 1st one cut off. The reason is that WPF uses the underscore character for marking accelerator keys.
If left as is, it will certainly confuse a small number of end-users. The majority of course will not notice, which still cannot excuse the developer from fixing the issue. Declaring it a feature in user manual is even more laughable because nobody ever reads user manuals except for searching a phone number to call and swear at support.
So I need a solution. First I decided to choose a complex path. No, first of course I started to Google. And then the second step, I decided to try either an event handler or to start messing up with DataGridColumnHeader's style and template. The results were as ugly as unsatisfactory.
But then, bingo, came a solution. If this guy, the DataGridColumnHeader, likes to have underscores for breakfast then make sure it has one every time. So now I simply prefix headers with the underscore. The issue is resolved.
No comments:
Post a Comment