Prevent Multi-select in WPF Tab Control?
-
20-08-2019 - |
Question
It appears that in a WPF TabControl
the user can select multiple items, either via Ctrl-Click or Shift-Click.
Is there a property that controls this? Or do I have to handle the click/select event and explicitly unselect other items?
Solution
Thanks to Moore's comment, I was able to solve this.
Each TabItem
in the TabControl.Items
collection needs a control to display the content. My program is using a ListView
:
tabItem.Content = new System.Windows.Controls.ListView();
When creating each ListView
, set the SelectionMode
property to Single
.
(Why that isn't happening, if Single
is the default, is a mystery...)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow