Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ToggleButtonHelper.OnIsCheckedChanged() accepts type of "bool?". #172

Merged
merged 1 commit into from
Sep 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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