在ListBox中使用TextBoxes

本文关键字:TextBoxes ListBox | 更新日期: 2023-09-27 18:30:11

我有一个列表框,其中显示了标题列表。用户单击行以选择填充更多文本框的项目。

但是,我在列表框的每一行中使用的文本框都是不可点击的——光标变为文本选择光标。

还有什么我应该用的吗?

 <ListBox ItemsSource="{DynamicResource products}" Width="319" x:Name="productsListBox" Height="300">
    <ListBox.ItemTemplate>
      <DataTemplate>
        <TextBox Text="{Binding Title}" BorderThickness="0" IsReadOnly="True"/>
      </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

在ListBox中使用TextBoxes

模板中的只读TextBox可以替换为TextBlock

<DataTemplate>
    <TextBlock Text="{Binding Title}" BorderThickness="0"/>
</DataTemplate>