views:

11

answers:

1

Hi All, I have to develop a control having one datagrid. now datagridtextcolumn have to be binded with one property of collection created in viewmodel.

based on data i have do one thing... if for a row no of lines is more than 3 in last column's cell then show a button having text "More" with last cell else with text "Less" and on click of "More" button it should display full text data...

now this layout can be shrined as well as stretched at runtime according to window's height and width using viewbox control or any other way...

so how to achieve this thing any idea???

A: 

Basically you want a custom textblock control that displays a max of 3 lines and shows a more button (if there are more than 3 lines of text)*.

The more button expands the textblock and I imagine stays around to collapse it again?

As it sounds like you only have one column (more like a list), rather than customise the datagrid create a usercontrol (with a grid, textblock and button) that does what you want and bind that inside a templated column instead.

You will need to expose the Text property as a dependency property for it to bind to. Most of the details of creating this type of usercontrol are on my answer to this: http://stackoverflow.com/questions/3713414/putting-button-inside-a-textblockor-maybe-something-else-to-make-it-work-like-t/3715709#3715709

Just add your size logic and change the layout to suit your needs.

*Note: Personally I would use the MinHeight property of the usercontrol to set when the "More" button is needed, then it will be more flexible, but that is just a suggestion.

Enough already