开发者

Nicely formatted multi-line text in Silverlight 4

I want to have a multiline text nicely formatted and displayed in silverlight 4.0. I think, it would be nice to use TextBox for that purpose (possibility of adjusting the background color and so forth).

My text would like like the following:

First row            aaaaaaa   
Second row           bbbbbbbb  
Third row            53456.00
Fourth row           66

Basically, what is the best approach to get nic开发者_运维问答ely formatted text - I want to "first... row" to be aligned left, wheres "aaaa ...." aligned right for each row.

Thanks for the clues and hints!

Cheers


Looks to me like you are after an items control, here is a starter:-

     <ItemsControl ItemsSource="{Binding YourData}">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="{Binding RowText}" />
                    <TextBlock Text="{Binding RowValue}" Grid.Column="1"/>
                </Grid>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>


By TextBox, I assume you mean RichTextBox. You may have some options with it's formatting tags. You'll most lilkey best off with the the broad range of layout controls already at your disposal. From the example, it would appear that the Grid would be your element of choice.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜