如何在WPF中为ListBoxItem加下划线?

如何在WPF中为ListBoxItem加下划线?,wpf,formatting,listboxitem,Wpf,Formatting,Listboxitem,如何在WPF中为ListBoxItem加下划线?我正在使用以下命令,但下划线没有出现 <DataTemplate x:Key="Phrase_List"> <ListBoxItem IsSelected="{Binding IsDefault}"> <TextBlock Text="{Binding Path=Phrase}" Tag="{Binding Path=ID}" TextDecorations="Underline" />

如何在WPF中为ListBoxItem加下划线?我正在使用以下命令,但下划线没有出现

<DataTemplate x:Key="Phrase_List">
    <ListBoxItem IsSelected="{Binding IsDefault}">
        <TextBlock Text="{Binding Path=Phrase}" Tag="{Binding Path=ID}" TextDecorations="Underline"  />
    </ListBoxItem>
</DataTemplate>

我不知道你想用什么代码。请试着完成你的问题。我已经使用以下代码在我的小列表框中的“World”项下划线

    <ListBox>
        <ListBoxItem>Hello</ListBoxItem>
        <ListBoxItem>
            <Underline>World</Underline>
        </ListBoxItem>
    </ListBox>

你好
世界

我不知道你想用什么代码。请试着完成你的问题。我已经使用以下代码在我的小列表框中的“World”项下划线

    <ListBox>
        <ListBoxItem>Hello</ListBoxItem>
        <ListBoxItem>
            <Underline>World</Underline>
        </ListBoxItem>
    </ListBox>

你好
世界

您可以使用textblock,并将TextEditions属性设置为下划线。请记住,ListBoxItem的内容可以是文本以外的内容,因此它不是在ListBoxItem上设置某些属性的简单情况

您可以使用textblock,并将TextEditions属性设置为下划线。请记住,ListBoxItem的内容可以是文本以外的内容,因此它不是在ListBoxItem上设置某些属性的简单情况

您将需要创建一个在TextBlock控件中显示文本的项目模板。在TextBlock上,将TextEditions属性(它是一个集合)设置为包含“下划线”。

您需要创建一个项目模板,在TextBlock控件中显示文本。在TextBlock上,将TextEditions属性(它是一个集合)设置为包含“下划线”。

在XAML中:

<ListBox Name="lst">
      <ListBoxItem Content="item1" />
      <ListBoxItem Content="item2" FontStyle="Italic" FontWeight="Normal" />
</ListBox>
在XAML中:

<ListBox Name="lst">
      <ListBoxItem Content="item1" />
      <ListBoxItem Content="item2" FontStyle="Italic" FontWeight="Normal" />
</ListBox>