In WPF, I\'d like to set the selected indexes of a System.Windows.Controls.ListBox
I best way I\'ve found so far is to remove all the items from the control, insert
Thanks to mdm20.
My case was actually checking a CheckBox
within the ListBox
, and this Dependency Property worked like a charm.
I had to inherit my custom class from DependencyObject
and implement the property
public class ProjectListItem : DependencyObject{
public Boolean IsChecked
{
get { return (Boolean)this.GetValue(CheckedProperty); }
set { this.SetValue(CheckedProperty, value); }
}
public static readonly DependencyProperty CheckedProperty =
DependencyProperty.Register("IsChecked", typeof(Boolean), typeof(ProjectListItem),
new PropertyMetadata(false));
}