开发者

DataGrid column header with a text box for filtering

I'm having a bit of problems creating a DataGrid with a header label AND a text box (at this point I'm not even entirely sure this is possible).

Here's what I want to do:

I need to dynamically create a table (the number of columns can and will change, so the grid needs to be created dynamically and cannot use bindings specified in the XAML code or similar). All the columns however will always be text columns.

Because those will be text columns, I'd like to add a text box to each header to enable simple filtering of the data in the DataGrid. I don't want to add extra text fields to OTHER parts of the Silverlight page, as I want to keep things as compact as possible. Also, since the number of columns is dynamic, adding a large number of text boxes above the DataGrid wouldn't look too good either. ;)

Also, if possible, I'd like to keep a label in each header to display the nam开发者_如何学Pythones of the columns as well.

So far I've tried adding the a TextBox as the Header of a DataGridTextBoxColumn but when I do that in a very simple Silverlight project, the whole DataGrid won't show up.

Please help.

EDIT: I saw the answer to this question: placing a text box inside the silverlight data grid column header

However, the answer itself didn't give me much to go on (the example is too short, and I'm not too good with XAML yet), and the code on CodePlex just adds extra fields to the Silverlight page. None of it tackles the problem of dynamically creating the DataGrid.


OK, here's what I did that solved my issue... I had to use a Style to achieve the functionality of having an extra text box inside each column header and filling out the Tag property of each thus created TextBox to later find out which column has been changed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜