9 changed files with 105 additions and 34 deletions
@ -1 +1 @@ |
|||
Subproject commit aef10ae67dc55c95f49b52a505a0be33bfa297a5 |
|||
Subproject commit 4464343aef5c8ab7a42fcb20a483a6058199f8b8 |
|||
@ -0,0 +1,35 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Avalonia.Controls.Notifications; |
|||
using Avalonia.Threading; |
|||
|
|||
namespace ControlCatalog.ViewModels |
|||
{ |
|||
class MainWindowViewModel |
|||
{ |
|||
public MainWindowViewModel() |
|||
{ |
|||
Dispatcher.UIThread.InvokeAsync(async () => |
|||
{ |
|||
await Task.Delay(5000); |
|||
|
|||
NotificationManager.Instance.Show(new NotificationViewModel { Title = "Warning", Message = "Please save your work before closing." }, "Main"); |
|||
|
|||
await Task.Delay(1500); |
|||
NotificationManager.Instance.Show(new NotificationContent { Message = "Test2", Type = NotificationType.Error }, "Main"); |
|||
|
|||
await Task.Delay(2000); |
|||
NotificationManager.Instance.Show(new NotificationContent { Message = "Test3", Type = NotificationType.Warning }, "Main"); |
|||
|
|||
await Task.Delay(2500); |
|||
NotificationManager.Instance.Show(new NotificationContent { Message = "Test4", Type = NotificationType.Success }, "Main"); |
|||
|
|||
await Task.Delay(500); |
|||
NotificationManager.Instance.Show("Test5", "Main"); |
|||
|
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace ControlCatalog.ViewModels |
|||
{ |
|||
public class NotificationViewModel |
|||
{ |
|||
public string Title { get; set; } |
|||
public string Message { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
<UserControl xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
x:Class="ControlCatalog.Views.NotificationView"> |
|||
<Border Padding="12" MinHeight="20" Background="#FF444444"> |
|||
<Grid> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="Auto"/> |
|||
<ColumnDefinition Width="*"/> |
|||
</Grid.ColumnDefinitions> |
|||
<ContentControl Margin="0,0,12,0" Width="25" Height="25" VerticalAlignment="Top"> |
|||
<TextBlock Text="" FontFamily="Segoe UI Symbol" FontSize="20" TextAlignment="Center" VerticalAlignment="Center"/> |
|||
</ContentControl> |
|||
<DockPanel Grid.Column="1"> |
|||
<TextBlock DockPanel.Dock="Top" Text="{Binding Title}" FontWeight="Medium" /> |
|||
<DockPanel LastChildFill="False" DockPanel.Dock="Bottom" Margin="0,8,0,0"> |
|||
<Button x:Name="Ok" Content="Ok" DockPanel.Dock="Right" /> |
|||
<Button x:Name="Cancel" Content="Cancel" DockPanel.Dock="Right" Margin="0,0,8,0" /> |
|||
</DockPanel> |
|||
<TextBlock Text="{Binding Message}" TextWrapping="Wrap" Opacity=".8" Margin="0,8,0,0"/> |
|||
</DockPanel> |
|||
</Grid> |
|||
</Border> |
|||
</UserControl> |
|||
@ -0,0 +1,19 @@ |
|||
using Avalonia.Controls; |
|||
using Avalonia.Controls.Primitives; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace ControlCatalog.Views |
|||
{ |
|||
public class NotificationView : UserControl |
|||
{ |
|||
public NotificationView() |
|||
{ |
|||
this.InitializeComponent(); |
|||
} |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue