开发者

Multiline Cell in Silverlight DataGrid

I am using the standard DataGrid control in Silverlight 4. All data is readonly, i.e. no cell is editable.

Does anybody know how to display text in a cell such that 开发者_如何学Pythonit automatically wraps to the next line(s) (in the same cell) when the cell border is reached?

Any feedback is much appreciated.


In the column definition set the TextWrapping property to "Wrap":

    <sdk:DataGridTextColumn 
        Header="Address"
        Width="150"
        Binding="{Binding Address}" >
        <sdk:DataGridTextColumn.ElementStyle>
            <Style TargetType="TextBlock">
                <Setter Property="TextWrapping" Value="Wrap"/>
            </Style>
        </sdk:DataGridTextColumn.ElementStyle>
    </sdk:DataGridTextColumn>

Source


I don't think this is going to work. Try using a template column, put the TextBlock in there set HorizontalAlignment and VerticalAlignment to stretch and make sure to set the margins.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜