开发者

wpf selecting controls inside a listbox

I have a textbox and some labels inside the data template of bounded listbox.

When I click on any l开发者_如何转开发abel the whole item is highlighted in blue, but when I click directly on a different textbox the selection does not change.

Is there a way to make the selection of the listbox change even when a textbox is clicked?

thanks


This is what I've exactly asked few days ago, see post: "WPF: Trigger SelectedIndex changed whilst clicking on any control within a ListBoxItem area"

basically there are few solutions, using code behind and XAML, but I've not verified latter approach yet


The reason is because the TextBox handles the click event in order to receive focus. There are a number of ways to handle this, including but not limited to:

  • stop the TextBox handling mouse events (which prevents the user from focussing it using the mouse)
  • use an eventhandler when the TextBox gains focus (or PreviewClick or similar), to select the parent ListItem
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜