Skip to content

Commit 554d254

Browse files
committed
refactor TValue<T> to record and move to Helpers
1 parent fa843ab commit 554d254

3 files changed

Lines changed: 30 additions & 21 deletions

File tree

src/Helpers/TValue.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
namespace WinUI.TableView.Helpers;
2+
3+
/// <summary>
4+
/// Represents a value type wrapper that enables implicit conversion between the wrapped value and the wrapper type.
5+
/// </summary>
6+
/// <typeparam name="T">The value type to be wrapped. Must be a struct.</typeparam>
7+
/// <param name="Value">The value to wrap.</param>
8+
internal record TValue<T>(T Value) where T : struct
9+
{
10+
/// <summary>
11+
/// Defines an implicit conversion from a TValue<T> instance to its underlying value of type T.
12+
/// </summary>
13+
public static implicit operator T(TValue<T> value)
14+
{
15+
return value.Value;
16+
}
17+
18+
/// <summary>
19+
/// Defines an implicit conversion from the underlying value type to a TValue<T> instance.
20+
/// </summary>
21+
public static implicit operator TValue<T>(T value)
22+
{
23+
return new(value);
24+
}
25+
}

src/TableView.Properties.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Linq;
99
using System.Runtime.CompilerServices;
1010
using System.Threading.Tasks;
11+
using WinUI.TableView.Helpers;
1112

1213
namespace WinUI.TableView;
1314

@@ -263,7 +264,7 @@ public partial class TableView
263264
/// <summary>
264265
/// Identifies the <see cref="ShowFilterItemsCount"/> dependency property.
265266
/// </summary>
266-
public static readonly DependencyProperty ShowFilterItemsCountProperty = DependencyProperty.Register(nameof(ShowFilterItemsCount), typeof(bool), typeof(TableView), new PropertyMetadata(false));
267+
public static readonly DependencyProperty ShowFilterItemsCountProperty = DependencyProperty.Register(nameof(ShowFilterItemsCount), typeof(bool), typeof(TableView), new PropertyMetadata(false));
267268

268269
/// <summary>
269270
/// Gets or sets a value indicating whether opening the column filter over header right-click is enabled.
@@ -360,6 +361,9 @@ public bool ShowFilterItemsCount
360361
/// </summary>
361362
internal bool IsEditing { get; private set; }
362363

364+
/// <summary>
365+
/// Gets the visibility states of details pane for each item.
366+
/// </summary>
363367
internal ConditionalWeakTable<object, TValue<bool>> DetailsPaneStates { get; } = [];
364368

365369
/// <summary>

src/TableViewRowPresenter.cs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,6 @@
1414

1515
namespace WinUI.TableView;
1616

17-
internal class TValue<T> where T : struct
18-
{
19-
public TValue(T value)
20-
{
21-
Value = value;
22-
}
23-
24-
public T Value { get; }
25-
26-
public static implicit operator T(TValue<T> value)
27-
{
28-
return value.Value;
29-
}
30-
31-
public static implicit operator TValue<T>(T value)
32-
{
33-
return new(value);
34-
}
35-
}
36-
3717
/// <summary>
3818
/// Represents a control that presents visuals for the <see cref="WinUI.TableView.TableViewRow"/>.
3919
/// </summary>

0 commit comments

Comments
 (0)