BililiveRecorder/BililiveRecorder.WPF/Converters/NullValueTemplateSelector.cs

15 lines
433 B
C#
Raw Normal View History

2020-11-27 18:51:02 +08:00
using System.Windows;
using System.Windows.Controls;
2021-02-23 18:03:37 +08:00
#nullable enable
2020-11-27 18:51:02 +08:00
namespace BililiveRecorder.WPF.Converters
{
internal class NullValueTemplateSelector : DataTemplateSelector
{
2021-02-23 18:03:37 +08:00
public DataTemplate? Normal { get; set; }
public DataTemplate? Null { get; set; }
2020-11-27 18:51:02 +08:00
2021-02-23 18:03:37 +08:00
public override DataTemplate? SelectTemplate(object item, DependencyObject container) => item is null ? this.Null : this.Normal;
2020-11-27 18:51:02 +08:00
}
}