Code Reilef with Tim Valentine
CodeRelief.net
Posts Tagged Selector
Auto-Select First Item Using XAML for Selector-Derived Controls (ListBox, ListView, TabControl, etc)
Posted by Tim Valentine in WPF on July 9, 2009
Problem
When your application has a control on it that derives from Selector and has no items on load nothing is selected. During run-time when the user is clicking around and adds items to the Selector-derived control, you would assume that the control would automatically select the first item because that only makes sense. However, your assumption and mine would be wrong; this is not the behavior at all. Instead the selector will still have no items selected. This means in order to get this “auto-select first item” behavior, you have to do it yourself. Luckily its an easy fix as shown below.
Categories
- General (6)
- VSTO (1)
- WPF (11)
- Controls (6)
- Bug Patches (3)
- Customization (4)
- Controls (6)
- Access Keys AccessKeysManager Animation Arrays Attached Properties Bug Patch Button C# Casting Code Generation COM ContextMenu Controls DataGrid DataGridColumn DataGridColumnHeader Dynamic Dynamic Classes Exception Frame-based Hashtable Hide ListBox ListBoxItem ListView ListViewItem Maximize MenuItem MessageBar Minimize MVC Run-time Scope Scoping SelectAllCommand Selector Show Style Styles VSTO Window WindowCustomizer WindowHelper Windows Forms WinForms WPF XAML
Archives
- June 2014 (1)
- July 2012 (2)
- March 2012 (2)
- November 2011 (1)
- August 2011 (1)
- April 2011 (1)
- January 2011 (3)
- April 2010 (1)
- March 2010 (1)
- February 2010 (1)
- July 2009 (2)
- June 2009 (1)
- May 2009 (1)