Skip to content

Commit 06fb7ca

Browse files
authored
Merge pull request #4827 from comintern/bugfix
TODO Explorer refresh
2 parents d70da54 + 883615d commit 06fb7ca

File tree

6 files changed

+281
-470
lines changed

6 files changed

+281
-470
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System;
2+
using System.Globalization;
3+
using System.Windows.Data;
4+
using Rubberduck.UI.ToDoItems;
5+
6+
namespace Rubberduck.UI.Converters
7+
{
8+
public class ToDoItemGroupingToBooleanConverter : GroupingToBooleanConverter<ToDoItemGrouping> { }
9+
10+
/// <summary>
11+
/// Provides a mutually exclusive binding between an ToDoItemGrouping and a boolean.
12+
/// Note: This is a stateful converter, so each bound control requires its own converter instance.
13+
/// </summary>
14+
public class GroupingToBooleanConverter<T> : IValueConverter where T : IConvertible, IComparable
15+
{
16+
private T _state;
17+
18+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
19+
{
20+
if (!(parameter is T governing) ||
21+
!(value is T bound))
22+
{
23+
return false;
24+
}
25+
26+
_state = bound;
27+
return _state.Equals(governing);
28+
}
29+
30+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
31+
{
32+
if (!(parameter is T governing) ||
33+
!(value is bool isSet))
34+
{
35+
return _state;
36+
}
37+
38+
_state = isSet ? governing : _state;
39+
return _state;
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)