Silverlight DataGrid - simulate Outlook AutoPreview
I want to use the Silverlight DataGrid to show notes. When they select an item in the grid I am going to show the note in a different area of the screen. However, I am hoping to also do something similar to Outlook AutoPreview, where the first few lines of the note are shown beneath each row in the grid.
What is the开发者_如何学C best way to accomplish this with the Silverlight DataGrid? Or, is there an alternative third party tool that would be better suited?
This is Silverlight 4 if it helps.
Is it not possible to simply change the contents of the DataGrid row to include not just the 'title' of the note, but also the first few lines of the node, prior to binding?
p.s. this assumes that you want to have all the rows in the DataGrid show the first few lines of the note, and not just the one which is selected (this makes more sense to me, since once it's selected, you already show the entire contents of the node in a separate control)
I am answering my own question because I ended up figuring it out. I dropped a DataGrid in Blend, and edited a copy of the RowStyle template. There is a part of the template where you can find this control:
<sdk:DataGridDetailsPresenter x:Name="DetailsPresenter" .../>
All of the contents of the row are rendered inside that control. Initially that control also has Grid Row and Column properties in it. I surrounded that control in a StackPanel and moved the grid properties to that new StackPanel. Then, after that control I created a TextBlock control with TextWrapping="Wrap" and TextTrimming="WordEllipsis". I also gave it the right colors, font, height, margins, etc. to make it look right.
In the end it looks almost exactly like Outlook AutoPreview.
精彩评论