开发者

Cannot click and select item in a listview (WPF)

I have a listview with following column

 <GridViewColumn Header="name" local:GridViewSort.PropertyName="Name">
   <GridViewColumn.CellTemplate>
     <DataTemplate>
       <TextBox Text="{Binding Name}" IsReadOnly="{Binding IsReadOnly}" Style="{StaticResour开发者_Go百科ce txtEditable}" KeyDown="SeqRenameTextBox_KeyDown" LostFocus="SeqRenameTextBox_LostFocus" />
     </DataTemplate>
   </GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn>
 ...
</GridViewColumn>

The problem is when I click on the TextBox, the listview doesn't select the item. Only when I click on the other normal column it will select the item.

Is there anything (e.g. TextBox inside) that will block the ListView from select the item?

Many thanks in advance.


Yes, it's the default behavior!

The text box will grab focus and it will not get to the listview item! What you can do as a hack is in your item container subscribe to the preview mouse down event and force a selectection of the listviewitem!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜