Skip to content

MVUX Command for new window throws exception #16653

Answered by dr1rrb
sosuisen asked this question in Q&A
Discussion options

You must be logged in to vote

You need to get access to the dispatcher.

If you are using navigation from the extensions you can simply add an Uno.Extensions.IDispatcher parameter to your constructor to get it injected by the DI.

eg:

using Uno.Extensions;

namespace MultiWindowTestXamlMVUX;

internal partial record MainModel(IDispatcher Dispatcher)
{
    public ValueTask OpenWindow(CancellelationToken ct)
       => Dispatcher.ExecuteAsync(() => 
       {
            var window = new Window();
            window.Activate();
       }, ct);
}

If you are instantiating your model directly in the code behind of your page, you can simply pass the DispatcherQueue (still in the ctor).

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@francoistanguay
Comment options

Comment options

You must be logged in to vote
4 replies
@agneszitte
Comment options

@sosuisen
Comment options

@sosuisen
Comment options

@francoistanguay
Comment options

Answer selected by sosuisen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
kind/bug Something isn't working triage/needs-information Indicates an issue needs more information in order to work on it.
5 participants
Converted from issue

This discussion was converted from issue #16646 on May 09, 2024 14:21.