Skip to content

Generic Dialog Manager example. #136

@Shadowblitz16

Description

@Shadowblitz16

Topics to cover

It would be nice if there was an example on how to show a window or dialog from a generic view model.

	public static void ShowWindow<T>(this T context, string title, uint width, uint height) where T : BaseViewModel
	{
		var topLevel = DialogManager.GetTopLevelForContext(context);
		if (topLevel != null && !Windows.TryGetValue(typeof(T), out var window))
		{
			window = new Window();
			window.Content = ViewLocator.Get(context);
			window.Title   = title;
			window.Width   = width;
			window.Height  = height;

		}
		window.Show();
	}
<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:vm="using:EditorX.Avalonia.ViewModels"
             xmlns::services="using:EditorX.Avalonia.Services"
             mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
             x:Class="EditorX.Avalonia.Views.LayerView"
             x:DataType="vm:LayerViewModel"
             services:DialogManager.Register={Binding}>

Ideas for a sample

  • Showing window
  • Hiding Window
  • Toggling window
  • Async Dialog
  • Mvvm view model based
  • Similar setup to dialog example by registering it to a user control.

Additional context

Na

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions