CodeRelief.net
Posts Tagged ListView
WPF: Non-selectable ListBoxItem and ListViewItem
Posted by Tim Valentine in Controls, Customization, WPF on January 4, 2011
Problem
Sometimes in WPF you want to have a list of items contained in a ListBox (or ListView) that you don’t want to be selectable. You could set those items to be disabled, by assigning IsEnabled to False, but that may interfere with styles among other things. You could also (probably the best idea) use a ItemsControl, from which the ListBox derives, that doesn’t include selectable-items functionality. However, for whatever reason, you may just want to use a ListBox (or ListView) instead.
Solution
Attached Properties, C#, Controls, ListBox, ListBoxItem, ListView, ListViewItem, Styles, WPF, XAML
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)