Skip to content
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
32 changes: 31 additions & 1 deletion MaterialDesign3.Demo.Wpf/Domain/DemoItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using MaterialDesignThemes.Wpf;

namespace MaterialDesign3Demo.Domain
{
Expand All @@ -15,12 +16,17 @@ public class DemoItem : ViewModelBase
private ScrollBarVisibility _verticalScrollBarVisibilityRequirement = ScrollBarVisibility.Auto;
private Thickness _marginRequirement = new(16);

public DemoItem(string name, Type contentType, IEnumerable<DocumentationLink> documentation, object? dataContext = null)
private int _notificationNumber = 0;

public DemoItem(string name, Type contentType, IEnumerable<DocumentationLink> documentation,
PackIconKind selectedIcon, PackIconKind unselectedIcon, object? dataContext = null)
{
Name = name;
_contentType = contentType;
_dataContext = dataContext;
Documentation = documentation;
SelectedIcon = selectedIcon;
UnselectedIcon = unselectedIcon;
}

public string Name { get; }
Expand All @@ -29,6 +35,18 @@ public DemoItem(string name, Type contentType, IEnumerable<DocumentationLink> do

public object? Content => _content ??= CreateContent();

public PackIconKind SelectedIcon { get; set; }
public PackIconKind UnselectedIcon { get; set; }

public object? Notifications
{
get
{
if (_notificationNumber == 0) return null;
else return _notificationNumber < 100 ? _notificationNumber : "99+";
}
}

public ScrollBarVisibility HorizontalScrollBarVisibilityRequirement
{
get => _horizontalScrollBarVisibilityRequirement;
Expand Down Expand Up @@ -57,5 +75,17 @@ public Thickness MarginRequirement

return content;
}

public void AddNewNotification()
{
_notificationNumber++;
OnPropertyChanged(nameof(Notifications));
}

public void DismissAllNotifications()
{
_notificationNumber = 0;
OnPropertyChanged(nameof(Notifications));
}
}
}
Loading