Skip to content

Commit

Permalink
ToggleButtonHelper.OnIsCheckedChanged() accepts type of "bool?".
Browse files Browse the repository at this point in the history
  • Loading branch information
nishy2000 committed Sep 23, 2015
1 parent 1d0b6ba commit 1517b45
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Fluent/Helpers/ToggleButtonHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ public static object CoerceIsChecked(DependencyObject d, object basevalue)
/// </summary>
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;
}
Expand Down
2 changes: 1 addition & 1 deletion FluentTest/TestContent.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@
<Fluent:ToggleButton Header="Toggle 2"
GroupName="Group1" />
<Fluent:ToggleButton Header="Toggle 3"
GroupName="Group1" />
GroupName="Group1" IsChecked="{Binding Path=IsCheckedToggleButton3}"/>
</Fluent:RibbonGroupBox>

<Fluent:RibbonGroupBox>
Expand Down
14 changes: 14 additions & 0 deletions FluentTest/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class MainViewModel : ViewModel
private double zoom;
private ICommand testCommand;
private string[] manyItems;
private bool? isCheckedToggleButton3;

public MainViewModel()
{
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 1517b45

Please sign in to comment.