uwp

How to check if user is idle on UWP? [duplicate]

无人久伴 提交于 2019-12-23 19:12:16
问题 This question already has an answer here : Detect if user Idle on windows universal app (1 answer) Closed 3 years ago . I wanted to make a function that would timeout and navigate to the main page if the user is idle for a certain period of time. After a little research, I found that the ThreadPoolTimer should suit my needs. Testing it I decided to use a 10 sec interval. timer =ThreadPoolTimer.CreatePeriodicTimer(Timer_Tick,TimeSpan.FromSeconds(10)); And this is where I'm at a loss. I couldn

[UWP]占领标题栏

本秂侑毒 提交于 2019-12-23 18:10:35
1. 前言 每一个有理想的UWP应用都会打标题栏的主意,尤其当微软提供 将 Acrylic 扩展到标题栏 这个功能后,大部分Windows 10的原生应用都不乖了,纷纷占领了标题栏的一亩三分地。这篇博客将介绍在UWP中如何自定义标题栏。 2.示例代码 UWP的限制很多,标题栏的自定义几乎全部内容集中在 这篇文档 里面。但只参考这篇文章做起来还不够顺手,我参考了微软开源的计算器应用中的 TitleBar 写了一个示例应用,可以在 这里 查看它的源码。我也把TitleBar实际应用到了我的 OnePomodoro 应用里面了。 3. 简单的颜色自定义 如果只想简单地自定义标题栏的颜色可以通过 ApplicationViewTitleBar ,ApplicationViewTitleBar表示应用程序的标题栏,它提供了一些颜色属性用于控制标题栏的颜色,示例代码如下: // using Windows.UI.ViewManagement; var titleBar = ApplicationView.GetForCurrentView().TitleBar; // Set active window colors titleBar.ForegroundColor = Windows.UI.Colors.White; titleBar.BackgroundColor = Windows.UI

Can not call Task.Run() at backgroundTask

泄露秘密 提交于 2019-12-23 17:33:50
问题 I want to do something in thread at background task, so I tried using Task.Run() but it does not work. Anyone can show me another way to create thread in background task. This is my code: public sealed class KatzBackgroundTask : IBackgroundTask { public void Run(IBackgroundTaskInstance taskInstance) { RawNotification notification = (RawNotification)taskInstance.TriggerDetails; string content = notification.Content; System.Diagnostics.Debug.WriteLine(content); testLoop(); } async void testLoop

UsbDevice.FromIdAsync returns null

主宰稳场 提交于 2019-12-23 17:03:12
问题 I have this code: private async void OnDeviceAdded(DeviceWatcher watcher, DeviceInformation deviceInformation) { if (deviceInformation.Name.StartsWith("ClearShot") && deviceInformation.IsEnabled) { targetDevice = await UsbDevice.FromIdAsync(deviceInformation.Id); OnConnected(EventArgs.Empty); } } This is actually an event that is called from a DeviceWatcher The problem is that targetDevice is always null. No crashes no nothing, It's just null, doesn't change. Why ? Edit: This is the thing

Capture speaker output

若如初见. 提交于 2019-12-23 16:40:19
问题 I've seen that I can capture the microphone and sound-files with elements in the Windows.Media.Audio namespace. I'm looking to capture the speaker output , though. For example, I click on something and the system sounds the alert sound - I want to be able to capture that. Is there any way of doing that using elements in Windows.Media.Audio (instead of going more low level into Win32 calls)? 回答1: Well, even with "low level Win32 calls", you can't do any loopback recording in UWP. This is

Pivot Header style

核能气质少年 提交于 2019-12-23 16:19:05
问题 C# UWP Windows 10 project I need to set Pivot header style to something like this I has tried to use this example from stackoverflow, but not sucessful. Can you say how I can set rectangle (like on image) behind header text and change background color for selected unselected items? 回答1: As the answer you've mentioned, we can use PivotHeaderItem styles and templates to implement this. Firstly, we can copy the style from MSDN and put in into Page.Resources . Then add a Border in the Grid and

Windows 10 UWP app menu flyout inside menu item

做~自己de王妃 提交于 2019-12-23 15:55:23
问题 Is it possible to have a menu flyout inside a menu flyout item? <AppBarButton x:Name="Button" Icon="Add" Label="Create List"> <AppBarButton.Flyout> <MenuFlyout> <MenuFlyoutItem Text="b1"> <FlyoutBase.AttachedFlyout> <MenuFlyout x:Name="ItemsMenu" Placement="Left"> <MenuFlyoutItem Text="test1"/> <MenuFlyoutItem Text="test2"/> </MenuFlyout> </FlyoutBase.AttachedFlyout> </MenuFlyoutItem> <MenuFlyoutItem Text="b2" /> <MenuFlyoutItem Text="b3" /> <MenuFlyoutItem Text="b4" /> <MenuFlyoutItem Text=

UWP Template 10 and Service Dendency Injection (MVVM) not WPF

时光总嘲笑我的痴心妄想 提交于 2019-12-23 15:32:57
问题 I have spent over two weeks searching google, bing, stack overflow, and msdn docs trying to figure out how to do a proper dependency injection for a mobile app that I am developing. To be clear, I do DI every day in web apps. I do not need a crash course on what, who, and why DI is important. I know it is, and am always embracing it. What I need to understand is how this works in a mobile app world, and in particular a UWP Template 10 Mobile app. From my past, in a .net/Asp app I can

UWP Template 10 and Service Dendency Injection (MVVM) not WPF

痞子三分冷 提交于 2019-12-23 15:27:06
问题 I have spent over two weeks searching google, bing, stack overflow, and msdn docs trying to figure out how to do a proper dependency injection for a mobile app that I am developing. To be clear, I do DI every day in web apps. I do not need a crash course on what, who, and why DI is important. I know it is, and am always embracing it. What I need to understand is how this works in a mobile app world, and in particular a UWP Template 10 Mobile app. From my past, in a .net/Asp app I can

How to programmatically change background theme of Win 8.1 or Win 10 UWP app?

柔情痞子 提交于 2019-12-23 13:24:39
问题 I have an app for Windows Phone 8.1 and a UWP version of it. I'd like to change the background of the apps dynamically when it is changed in Windows. Use case would be: Start the app, the background theme is dark. Press the home button on the phone Change the background theme to light Go back to the app (basically switch to it from the background) The theme of the app would change automatically to the new theme I'd like it to be done like this, without a restart. I've seen this in other apps,