-
Notifications
You must be signed in to change notification settings - Fork 141
Expand file tree
/
Copy pathNullableBoolExtension.cs
More file actions
34 lines (29 loc) · 1.13 KB
/
NullableBoolExtension.cs
File metadata and controls
34 lines (29 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace CommunityToolkit.WinUI;
/// <summary>
/// Custom <see cref="MarkupExtension"/> which can provide nullable bool values.
/// See https://wpdev.uservoice.com/forums/110705-universal-windows-platform/suggestions/17767198-nullable-dependency-properties.
/// </summary>
[MarkupExtensionReturnType(ReturnType = typeof(bool?))]
public partial class NullableBoolExtension : MarkupExtension
{
/// <summary>
/// Gets or sets a value indicating whether the value of the Boolean is true. Ignored if <see cref="IsNull"/> is true.
/// </summary>
public bool Value { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the value should be null. Overrides the <see cref="Value"/> property.
/// </summary>
public bool IsNull { get; set; }
/// <inheritdoc/>
protected override object? ProvideValue()
{
if (IsNull)
{
return null;
}
return Value;
}
}