开发者

Silverlight Textblock set lines

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 i开发者_高级运维t 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???


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: putting Button inside a TextBlock(or maybe something else) to make it work like the one on video?

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜