0

我搜索了高低,但找不到与我的请求完全匹配的内容。我使用下面的代码将几个对象绑定到列表视图。项目 FaultDescription 是描述机器项目状态的字符串,包括项目的简要描述/标题。我的问题是 - 有没有一种方法可以让我在同一项目中使用粗体字体的标题,然后使用常规字体的其余文本?

例如“标题......这是文本的其余部分......”

顺便说一句,我在将列表视图绑定到的类的实例中使用 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>
4

1 回答 1

1

尝试以下操作:

<GridViewColumn.CellTemplate>
    <DataTemplate>
        <StackPanel Orientation="Horizontal">
            <TextBlock Text="{Binding Title}" FontWeight="Bold" />
            <TextBlock Text="{Binding Description}" />
        </StackPanel>
    </DataTemplate>
</GridViewColumn.CellTemplate>
于 2013-01-30T12:59:17.080 回答