From 1517b45d673183868db2883b916cdee87f06cc79 Mon Sep 17 00:00:00 2001 From: nishy2000 Date: Wed, 23 Sep 2015 23:26:09 +0900 Subject: [PATCH] ToggleButtonHelper.OnIsCheckedChanged() accepts type of "bool?". --- Fluent/Helpers/ToggleButtonHelper.cs | 4 ++-- FluentTest/TestContent.xaml | 2 +- FluentTest/ViewModels/MainViewModel.cs | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Fluent/Helpers/ToggleButtonHelper.cs b/Fluent/Helpers/ToggleButtonHelper.cs index 52f9d27ab..ab911d899 100644 --- a/Fluent/Helpers/ToggleButtonHelper.cs +++ b/Fluent/Helpers/ToggleButtonHelper.cs @@ -80,11 +80,11 @@ public static object CoerceIsChecked(DependencyObject d, object basevalue) /// public static void OnIsCheckedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var newValue = (bool)e.NewValue; + var newValue = (bool?)e.NewValue; var button = (IToggleButton)d; // Uncheck other toggle buttons - if (!newValue || button.GroupName == null) + if (!newValue.HasValue || !newValue.Value || button.GroupName == null) { return; } diff --git a/FluentTest/TestContent.xaml b/FluentTest/TestContent.xaml index 2422f1fb8..9e93522e7 100644 --- a/FluentTest/TestContent.xaml +++ b/FluentTest/TestContent.xaml @@ -1120,7 +1120,7 @@ + GroupName="Group1" IsChecked="{Binding Path=IsCheckedToggleButton3}"/> diff --git a/FluentTest/ViewModels/MainViewModel.cs b/FluentTest/ViewModels/MainViewModel.cs index fd03e0331..98b17aec6 100644 --- a/FluentTest/ViewModels/MainViewModel.cs +++ b/FluentTest/ViewModels/MainViewModel.cs @@ -22,6 +22,7 @@ public class MainViewModel : ViewModel private double zoom; private ICommand testCommand; private string[] manyItems; + private bool? isCheckedToggleButton3; public MainViewModel() { @@ -133,6 +134,19 @@ public string[] ManyItems get { return this.manyItems ?? (this.manyItems = this.GenerateStrings(5000)); } } + public bool? IsCheckedToggleButton3 + { + get { return this.isCheckedToggleButton3; } + set + { + if (this.isCheckedToggleButton3 != value) + { + this.isCheckedToggleButton3 = value; + this.OnPropertyChanged("ToggleButton3IsChecked"); + } + } + } + private string[] GenerateStrings(int count) { return Enumerable.Repeat("Test", count).ToArray();