private static void Setup(FrameworkElement element, ViewModel viewModel) { Binding binding; CheckBoxToggle.SetEnabled(element, true); binding = new Binding(nameof(ViewModel.IsChecked)) { Source = viewModel }; element.SetBinding(CheckBoxToggle.IsCheckedProperty, binding); }
public void StopsTogglingWhenPropertyIsDisabled() { ListViewItem item; ViewModel vm; item = new ListViewItem(); vm = new ViewModel(); Setup(item, vm); Assert.False(vm.IsChecked); SendKeyDown(item, Key.Space); SendKeyUp(item, Key.Space); Assert.True(vm.IsChecked); CheckBoxToggle.SetEnabled(item, false); SendKeyDown(item, Key.Space); SendKeyUp(item, Key.Space); Assert.True(vm.IsChecked); }