How to set XamlRoot for ContentDialog when using C# Markup + MVUX #18598
-
I want to open a ContentDialog through my Model,as the document said,I need to set the Xamlroot. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 11 replies
-
Hey @liziyu0714, Thanks for your question! I recommend creating a custom service that you initialize with a |
Beta Was this translation helpful? Give feedback.
-
Thanks! |
Beta Was this translation helpful? Give feedback.
-
Yes.I write an similar service to get xamlroot, and it works in MVVM template.
But in my project using mvux it doesn't work, just like yours. And I find that if you call showasync in loaded method(in mvux),it can work.
…________________________________
From: DevTKSS ***@***.***>
Sent: Saturday, November 2, 2024 12:46:56 AM
To: unoplatform/uno ***@***.***>
Cc: liziyu0714 ***@***.***>; Mention ***@***.***>
Subject: Re: [unoplatform/uno] How to set XamlRoot for ContentDialog when using C# Markup + MVUX (Discussion #18598)
@liziyu0714<https://github.com/liziyu0714>
thanks for reply.
So you got it working?
I am still struggeling to get the dialog shown sadly. Along documentation it should be possible to call this from Model after filling the xamlRoot to that service he gave in the zip file and filling the xamlroot in the loaded event. But (if you maybe seen my opened Question topic) on my end there is nothing showing up and instead the syncronizationContext seems to be suddenly null after going to the model to run the task instead of doing it in the Main Page. Does this happen on your side also using that service? It dont make any sense to me or the others (discussing also on discord) why that do happen.
—
Reply to this email directly, view it on GitHub<#18598 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AM4YCZDXS5SN5NFJOY4IRK3Z6OWABAVCNFSM6AAAAABQUWVRPWVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCMJSGQYTOMA>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
in mvvm template ,it can be called from model.But in mvux,it can't
…________________________________
From: DevTKSS ***@***.***>
Sent: Saturday, November 2, 2024 12:58:43 AM
To: unoplatform/uno ***@***.***>
Cc: liziyu0714 ***@***.***>; Mention ***@***.***>
Subject: Re: [unoplatform/uno] How to set XamlRoot for ContentDialog when using C# Markup + MVUX (Discussion #18598)
but... just a thought: If i can only call it from the loaded event method, I can not trigger it from a button command, so would that make any sense? Possibly I just misunderstood it
—
Reply to this email directly, view it on GitHub<#18598 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AM4YCZBOVYGUIDEZCKGY2ILZ6OXMHAVCNFSM6AAAAABQUWVRPWVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCMJSGQZTAMY>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
Hey @liziyu0714,
Thanks for your question! I recommend creating a custom service that you initialize with a
XamlRoot
(e.g., fromApp.cs
during startup). Once the app loads, this service can provide the value whenever you call it. For more details on opening aContentDialog
from a ViewModel, check out this guide: https://platform.uno/docs/articles/features/dialogs.html?tabs=mvux%2Ccs-markup#opening-a-contentdialog-from-a-modelviewmodelLet me know if this helps.