A content control that serves as the main view container for PleasantUI applications. Supports modal windows and a snackbar queue manager for displaying notifications.
<controls:PleasantView>
<StackPanel Spacing="8">
<TextBlock Text="Main content" />
<Button Content="Show Snackbar" />
</StackPanel>
</controls:PleasantView>| Property | Type | Description |
|---|---|---|
SnackbarQueueManager |
SnackbarQueueManager<PleasantSnackbar> |
Manager for displaying snackbar notifications |
ModalWindows |
AvaloniaList<PleasantPopupElement> |
Collection of modal windows |
Display snackbar notifications using the SnackbarQueueManager:
var snackbar = new PleasantSnackbar
{
Title = "Success",
Content = "Operation completed successfully"
};
pleasantView.SnackbarQueueManager.Enqueue(snackbar);Show modal windows by adding them to the ModalWindows collection:
var dialog = new ContentDialog
{
Title = "Confirm",
Content = "Are you sure?"
};
dialog.ShowAsync(window);The modal window automatically registers itself with the view.
The control inherits from ContentControl, so you can set any content:
<controls:PleasantView Content="{Binding MainContent}" />Or use content templates:
<controls:PleasantView>
<controls:PleasantView.ContentTemplate>
<DataTemplate>
<Border Background="White" Padding="16">
<ContentPresenter Content="{Binding}" />
</Border>
</DataTemplate>
</controls:PleasantView.ContentTemplate>
</controls:PleasantView>Style the view like any other ContentControl:
<Style Selector="controls:PleasantView">
<Setter Property="Background" Value="#F5F5F5" />
<Setter Property="CornerRadius" Value="8" />
<Setter Property="Padding" Value="16" />
</Style>The control template must provide:
PART_VisualLayerManager- Visual layer manager for modal windows and snackbarsPART_ContentPresenter- Content presenter for the main content
PleasantViewimplementsIPleasantWindowfor integration with the PleasantUI overlay system- The default template includes a visual layer manager for handling modal windows and snackbars
- Use this control as the root content container in PleasantUI applications