Reputation: 4297
Inside a UWP app I want to control some animations on a second screen from my main app window. As far as I can tell I have two options: create a second Window or use the projection feature.
My questions are:
Upvotes: 2
Views: 1041
Reputation: 2710
About Q2:
There are some way to interact with multi thread model. If you write your app based on the MultiView sample, you can use the SecondaryViewsHelper to call method on the another pages, etc. Or, you can call the LaunchUriAsync from each pages. If you regist your app as protocol handler, you can receive the call at OnLaunched method. This is common for both Projection and Multi-View.
This SO page also helps you :)
Multiple instances of a Windows Universal App (Windows 10)
Edited: Sample - It's used on my uwp app - added.
// This is a method of Application class "F10Client".
// SecondaryViews is a member of this class.
// In my app, this method is called when the app resumes.
public async Task<bool> TogglePrivateMaskForAllPages(bool isMask)
{
bool retVal = true;
if (null != ((F10Client)F10Client.Current).SecondaryViews && 0 < ((F10Client)F10Client.Current).SecondaryViews.Count)
{
foreach (var view in ((F10Client)F10Client.Current).SecondaryViews)
{
// You should use dispatcher to call the page method.
await view.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
var thePage = (ImagePage)((Frame)Window.Current.Content).Content;
// calling the method.
thePage.TogglePrivacyMask(isMask);
});
}
}
return retVal;
}
Upvotes: 2
Reputation: 4297
For my first question, the Guidelines for projection manager helped me choose the right way to go:
Upvotes: 1