Is there a way to display formatted rich text in WPF datagrid?
I'm trying to display rich text inside of a column of a WPF DataGrid (from WPF Toolkit). Something like this:
Name: Bob
Title: Doctor
I am creating a data object programmatically in code with the string property. And I want this string to contain the rich text and than bind it to the column contents. Is that possible?
Would really appreciate any help!
使用DataGridTemplateColumn:
<dg:DataGridTemplateColumn Header="Info">
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Text="Name:" FontWeight="Bold" Grid.Row="0" Grid.Column="0" />
<TextBlock Text="{Binding Name}" Grid.Row="0" Grid.Column="1" />
<TextBlock Text="Title:" FontWeight="Bold" Grid.Row="1" Grid.Column="0" />
<TextBlock Text="{Binding Title}" Grid.Row="1" Grid.Column="1" />
</Grid>
</DataTemplate>
</dg:DataGridTemplateColumn.CellTemplate>
</dg:DataGridTemplateColumn>
链接地址: http://www.djcxy.com/p/50514.html
上一篇: 如何使用WPF将文本包装到标签中?