Browse Source

CheckListBox: fixed bug when checking/unchecking the SelectedItem and the Command doesn't fire.

pull/1645/head
brianlagunas_cp 15 years ago
parent
commit
884a634e0c
  1. 7
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/CheckListBox/Implementation/CheckListBox.cs

7
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/CheckListBox/Implementation/CheckListBox.cs

@ -64,7 +64,7 @@ namespace Microsoft.Windows.Controls
protected virtual void OnSelectedItemChanged(object oldValue, object newValue) protected virtual void OnSelectedItemChanged(object oldValue, object newValue)
{ {
OnSelectionChanged();
} }
#endregion //SelectedItem #endregion //SelectedItem
@ -92,6 +92,7 @@ namespace Microsoft.Windows.Controls
if (!String.IsNullOrEmpty(CheckedMemberPath)) if (!String.IsNullOrEmpty(CheckedMemberPath))
{ {
Binding isCheckedBinding = new Binding(CheckedMemberPath); Binding isCheckedBinding = new Binding(CheckedMemberPath);
isCheckedBinding.Mode = BindingMode.TwoWay;
isCheckedBinding.Source = item; isCheckedBinding.Source = item;
checkListBoxItem.SetBinding(CheckListBoxItem.IsSelectedProperty, isCheckedBinding); checkListBoxItem.SetBinding(CheckListBoxItem.IsSelectedProperty, isCheckedBinding);
} }
@ -118,12 +119,14 @@ namespace Microsoft.Windows.Controls
{ {
SetSelectedItem(e.OriginalSource); SetSelectedItem(e.OriginalSource);
SelectedItems.Add(SelectedItem); SelectedItems.Add(SelectedItem);
OnCheckedChanged();
} }
void CheckListBox_Unselected(object sender, RoutedEventArgs e) void CheckListBox_Unselected(object sender, RoutedEventArgs e)
{ {
SetSelectedItem(e.OriginalSource); SetSelectedItem(e.OriginalSource);
SelectedItems.Remove(SelectedItem); SelectedItems.Remove(SelectedItem);
OnCheckedChanged();
} }
private void SetSelectedItem(object source) private void SetSelectedItem(object source)
@ -136,7 +139,7 @@ namespace Microsoft.Windows.Controls
SelectedItem = selectedCheckListBoxItem.DataContext; SelectedItem = selectedCheckListBoxItem.DataContext;
} }
private void OnSelectionChanged() private void OnCheckedChanged()
{ {
if (_surpressSelectionChanged) if (_surpressSelectionChanged)
return; return;

Loading…
Cancel
Save