UWP Modal Window - c#

I want to show a modal window on the screen in my Universal Windows Platform app (C#), just like the standard Mail-app does when you add an account. Or when you're signing in to a service (like facebook) in an app.
Windows mail app with modal window:
You can move this window around, but it's not in the taskbar and it is modal.
Does anyone know how to do this? It shouldn't be so hard but i can't find anything about it.

As #Daniel Meixner said, adding account interaction of this Mail app is calling another app possible with LaunchForResults.
Using Task Manager of system, you can see that, when you launch this Mail app, it starts a process with the app's name "Mail", and when you add an account from this app, it starts another process with the app's name "Email and accounts".
If we use the Process Explorer to check on these processes, the Mail app's process is this:
and the add account process is this:
They are in different processes and have different package names.
So I created two apps and use LaunchForResult for communication between these apps, they act just like the Mail app of system.
If you just want to launch the system's "add account" app, you can refer to the official UserDataAccountManager sample.

In the mail app what's happening might be app to app communication with "LaunchForResults" - I'm not sure, but it looks like that.
With Windows 10 Universal Apps you can make one app call another app with LaunchForResults. The called app will always behave like a modal dialog to the calling app.
You can pass any serializable objects in both directions using ValueSets.
Details for LaunchForResult can be found here:
https://msdn.microsoft.com/en-us/library/windows/apps/mt269386.aspx

It is possible to create a movable window, but you can't make it modal.
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/f1328991-b5e5-48e1-b4ff-536a0013ef9f/is-it-possible-to-open-a-new-window-in-uwp-apps?forum=wpdevelop

Related

Action Center Toast Notification without Shortcut

I've created a custom C#/WPF application that can send toast notifications that has an activator that can handle activation. I'm using WiX to deploy the solution and create a shortcut with ShortcutProperty elements for System.AppUserModel.ID and System.AppUserModel.ToastActivatorCLSID.
Everything works perfectly as expected but I wonder one thing. Is it possible to register the ToastActivator without creating a shortcut? This program is going to be used on an internal enterprise network and I don't intend for it to have any UI. It'll be launched by the Task Scheduler, check a web service and send toast messages to the user when they apply.
If I must have a shortcut, the best UX I can think of is to just diplay an about dialog and exit.
Based on the Application Model Microsoft has, any UWP feature like notification center, toasts etc can only be done by a registered application.
An application is "registered" when its added to the start menu with a link.
There has to be a valid shortcut with a System.AppUserModel.Id otherwise all the new win10 features do not work.
https://learn.microsoft.com/en-us/windows/win32/shell/quickstart-sending-desktop-toast

Balloon Tooltip using Windows Service C#

I want to open a balloon tooltip using windows service.
I can do it in Windows Forms. Is it possible using windows service ?
I have implemented this service before and used a named pipe. Basically you create two applications.
A windows service projects which acts as the Named Pipe Server
A winforms application with a tray icon, a balloon and a Named Pipe Client
The windows service pushes messages towards the clients that are connected, could be multiple users on the systems running the winforms app.
The winforms app listens to messages on the pipe. Once the message comes in you can make the balloon pop up.
Here is a cool test project: https://www.codeproject.com/Tips/492231/Csharp-Async-Named-Pipes
Happy coding!
Not directly. A windows service does not run in the user's session, it runs in its own special "Service Session". Tooltips that show up in that session don't show up on the users desktop.
The way to get around this normally is to have a 2nd program that starts with the user's login and is not visible in the taskbar. That program uses some form of IPC (for example WCF) to talk to the service, the service can then tell the helper program to show a notification as needed.

UWP app start automatically at startup

All is in the title, I currently searching a way to launch my UWP app automatically at Windows startup with the UWP framework only, no file manipulation on the machine. The application must be able to be shared on the Store AND open when Windows starts.
Is it a feasible thing? If so how?
Thank you!
#hsmiths wrote easist solution to start app automatically and I'd like to summarize in step by step.
Open File Explorer
In address bar, copy-and-paste shell:AppsFolder
Right-click the app and then click Create Shorcut.
The message box asks to create shorcut on the Desktop. Click Yes.
In File Explorer address bar, copy-and-paste shell:startup
Go to Desktop and copy-and-paste shorcut to File Explorer.
Reboot your computer if you want to test.
+Tip: if you want to by-pass login dialog on Windows startup.
Start > Run
type control userpasswords2
User Accounts window will be opened. Uncheck Users must enter a user name ...
When you click OK, you will be asked to enter account password. Type password.
Reboot your computer if you want to test.
It seems that MS will add this feature - windows.startupTask - not only for converted desktop apps, but also UWP apps.
You can see it from about 37:00
Tip, tricks, and secrets: Building a great UWP app for PC
But this feature is not ready yet - It'll be available with Windows 10 Fall Creators Update.(I've tried with SDK 16225 but not ready yet)
Added 12/18/2017 - You can do it with Win10 Fall Creators Update.Following post show the details.
Configure your app to start at log-in (Windows Blog)
One consideration point is: By the feature, you can just 'start' the app - the app window is not shown. To see the app window, the user should click the app task at the task bar. It's a slightly ridiculous implementation for me. From the view of customer, 'click to start' and 'click to activate' is same behavior. You can do the some task in background before the user activate the app, but this is an another story.
If it's a desktop application converted to UWP you can declare a startup task in your appmanifest like this:
<desktop:Extension Category="windows.startupTask" Executable="bin\MyStartupTask.exe"
EntryPoint="Windows.FullTrustApplication">
<desktop:StartupTask TaskId="MyStartupTask" Enabled="true" DisplayName="My App Service" />
</desktop:Extension>
See Converted desktop app extensions
You can on Windows 10 (I'm not sure about Windows 8 or earlier versions), here's the instructions from Microsoft:
https://learn.microsoft.com/en-us/windows/uwp/launch-resume/create-and-register-a-background-task
Even in Windows 10 IoT you can set an app to autostart through a PS command:
[192.168.0.243]: PS C:\> iotstartup list MyBackgroundApp
You can create a .bat script that execute "start AppID!App"
"AppID!App" string is available in shell:AppsFolder view, you have to add the given column.
Then place the .bat file in the startup folder:
"shell:startup" for the given user,
"c:\windows\system32\GroupPolicy\User\Scripts\Logon" for all the users of the given computer
I think that is not possible, but maybe you can use a trigger in order to activating a background task when something happen..
Here's a list of the available triggers:
SystemTrigger
MaintenanceTrigger
TimeTrigger
PushNotificationTrigger
NetworkOperatorNotificationTrigger
NetworkOperatorHotspotAuthenticationTrigger
However you have some constraint.. take a look here: http://blogs.msdn.com/b/windowsappdev/archive/2012/05/24/being-productive-in-the-background-background-tasks.aspx

Opening another WinRT app from another running app in FULL mode

I have 2 apps. I am running one in full mode and want to click a button from the first app to launch the second app .
My problem is that my second app is getting launched but both apps are in Snapped mode.
I programatically want to allow the other app to open in fill mode and first app should be in the memory.
Any help ?
Windows Store apps don't have any way to directly launch other apps. I assume you're launching a URI or file and your app is registered as the default handler (users can choose something else).
In your call to Launcher.LaunchUriAsync you can set the DesiredRemainingView in your LauncherOptions to indicate how much of the screen you'd like your app to keep. This is non-binding, but likely to be followed for UseNone. If there's room for UseHald (the default) then UseLess to snap/fill will likely be respected as well.

Application on windows startup C#

i have designed an application which validates users against online database and then allow users to work, after authentication it shows desktop, it loads on startup.
i would like to start my login application at windows start up, i have added my login application path to registry it is started well with windows. but it has one issue
first windows desktop appears few seconds and then my login application loaded
i would like to show my application before windows desktop
or
any other way to use windows login to validate user against online server database and then allow users to work.
If you don't want the desktop to show at all you can run your application as the Windows Shell.
You use this registry key
[HKEY_LOCAL_MACHINE\SOFTWARE\Micro­soft\Windows NT\CurrentVersion\Winlogon]
"Shell"="C:\\WINDOWS\\explorer.exe­"
The other solution is to use XP Embedded Standard so you can totally customise the Windows experience. Takes a lot more work than the simple shell replacement though, but much more robust
You could replace the shell as above, then have your application launch explorer.exe when you were ready to have the start menu and taskbar show up...

Categories

Resources