Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Moving code around to fix nullability warnings
  • Loading branch information
Keboo committed Jul 19, 2023
commit 475c97d2e3d899d51d207aba09f3a75d3137b2fa
33 changes: 17 additions & 16 deletions MainDemo.Wpf/Domain/TabsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,41 @@ internal class TabsViewModel : ViewModelBase

Nulla a porta libero, quis hendrerit ex. In ut pharetra sem. Nunc gravida ante rhoncus commodo aliquet. Integer luctus blandit libero, sed faucibus ligula ornare ut. Mauris facilisis, urna eu fermentum mollis, mauris massa commodo odio, a venenatis nunc nunc sollicitudin nibh. Ut mattis ipsum nec lacus mattis fringilla. Proin vulputate id velit a finibus. Ut nunc ex, elementum porttitor finibus vel, pellentesque vel turpis. Cras fringilla eleifend libero, ac feugiat arcu vehicula ornare. Nullam pretium finibus blandit. Etiam at urna facilisis, posuere felis non, congue velit. Pellentesque tortor erat, mattis at augue eu, egestas interdum nunc. Aliquam tortor lorem, venenatis eget vestibulum vitae, maximus eget nunc. Vestibulum et leo venenatis, rutrum lacus eget, mattis quam.";

public TabsViewModel() =>
public TabsViewModel()
{
var closeCommand = new AnotherCommandImplementation(_ =>
{
if (SelectedTab is { } selectedTab)
CustomTabs?.Remove(selectedTab);
});

CustomTabs = new()
{
new CustomTab
new CustomTab(closeCommand)
{
CustomHeader = "Custom tab 1",
CustomContent = "Custom content 1",
CloseCommand = CloseCommand
CustomContent = "Custom content 1"
},
new CustomTab
new CustomTab(closeCommand)
{
CustomHeader = "Custom tab 2",
CustomContent = "Custom content 2",
CloseCommand = CloseCommand
CustomContent = "Custom content 2"
},
new CustomTab
new CustomTab(closeCommand)
{
CustomHeader = "Custom tab 3",
CustomContent = "Custom content 3",
CloseCommand = CloseCommand
},
};

private ICommand CloseCommand => new AnotherCommandImplementation(_ =>
{
if (SelectedTab != null)
CustomTabs.Remove(SelectedTab);
});
}

}

internal partial class CustomTab : ObservableObject
{
public ICommand CloseCommand { get; set; }
public ICommand CloseCommand { get; }

public CustomTab(ICommand closeCommand) => CloseCommand = closeCommand;

[ObservableProperty]
private string? _customHeader;
Expand Down