Files
Ursa.Avalonia/demo/Ursa.Demo/ViewModels/BannerDemoViewModel.cs
2025-01-09 20:46:12 +08:00

41 lines
1021 B
C#

using CommunityToolkit.Mvvm.ComponentModel;
namespace Ursa.Demo.ViewModels;
public partial class BannerDemoViewModel : ViewModelBase
{
private string? _oldTitle = string.Empty;
private string? _oldContent = string.Empty;
[ObservableProperty] private string? _title = "Welcome to Ursa";
[ObservableProperty] private string? _content = "This is the Demo of Ursa Banner.";
[ObservableProperty] private bool _bordered;
[ObservableProperty] private bool _setTitleNull = true;
[ObservableProperty] private bool _setContentNull = true;
partial void OnSetTitleNullChanged(bool value)
{
if (value)
{
Title = _oldTitle;
}
else
{
_oldTitle = Title;
Title = null;
}
}
partial void OnSetContentNullChanged(bool value)
{
if (value)
{
Content = _oldContent;
}
else
{
_oldContent = Content;
Content = null;
}
}
}