我搜索过高和低,但无法找到与我的请求完全匹配。我使用下面的代码绑定几个对象列表视图。 FaultDescription项是一个字符串,用于描述机器项的状态,包括项的简要描述/标题。我的问题是 - 有没有一种方法可以让我的标题以粗体显示,然后是同一项中常规字体的其余文字?
例如“标题 ......这是文本的其余部分......”
BTW我在我将listview绑定到的类的实例中使用StringBuilder构建字符串。
非常感谢,
杰夫
C#:
lstvProductFaultState.Items.Add(newFaultRecord);
XAML:
<ListView FontSize="12" Height="252" HorizontalAlignment="Left" ItemsSource="{Binding}" Margin="251,261,0,0"
Name="lstvProductFaultState" VerticalAlignment="Top" Width="717" BorderThickness="2" BorderBrush="Black">
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding Path=FaultNumber}" Header="No." Width="18" />
<GridViewColumn Header="Rating" Width="40">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding FaultRatingImage}" Stretch="Uniform"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn DisplayMemberBinding="{Binding Path=Radius}" Header="Radius" Width="40" />
<GridViewColumn DisplayMemberBinding="{Binding Path=Edge}" Header="Edge" Width="40" />
<GridViewColumn DisplayMemberBinding="{Binding Path=FaultTitleAndDescription}" Header="Fault Details" Width="200" />
<GridViewColumn Header="Photo 1" Width="80">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding Image1}" Stretch="Uniform"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Photo 2" Width="80">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding Image2}" Stretch="Uniform"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Photo 3" Width="80">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding Image3}" Stretch="Uniform"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
答案 0 :(得分:1)
尝试以下方法:
<GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Title}" FontWeight="Bold" />
<TextBlock Text="{Binding Description}" />
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>