uwp

Converting XAML to PDF in an UWP app

这一生的挚爱 提交于 2019-12-30 05:05:07
问题 I have a Canvas element on a XAML page that I'm using as a printing root in my UWP app. I'm using events such as PrintManager.PrintTaskRequested and PrintDocument.Paginate to prepare my report and send it to a printer. I need to export the report programmatically to a PDF file. The ideal solution would somehow utilize the existing printing root (the Canvas), print to it, and then convert the result to PDF. After that, I would be able to save PDF to a file or attach it to an email. I've been

Density of screen in iOS and Universal WIndows App

微笑、不失礼 提交于 2019-12-30 04:12:28
问题 Hi I need to know the density of screen in windows 10/8/8.1 and iOS. I got screen density in Android using DisplayMetrics but I find no such option/property available in UWP and iOS. So Is there any property through which I can get screen density in UWP and IOS. 回答1: UPDATE - June 8th 2018 Xamarin has released Xamarin.Essentials! Xamarin.Essentials provides developers with cross-platform APIs for their mobile applications. Android, iOS, and UWP offer unique operating system and platform APIs

DataPackage.SetDataProvider doesn't wait (unlike its documentation states)

≡放荡痞女 提交于 2019-12-29 09:56:14
问题 DataPackage.SetDataProvider's documentation states: Use the SetDataProvider method when your app ... does not want to supply the data until the target app requests it. But when I run the following code it calls the callback method immediately. static void CopyToClipboardReference(string s) { DataPackage dataPackage = new DataPackage(); reference = s; dataPackage.SetDataProvider(StandardDataFormats.Text, CopyToClipboardAction); Clipboard.SetContent(dataPackage); } static string reference;

Send speech recognition args.Result as parameter in UWP desktop-bridge package

余生长醉 提交于 2019-12-29 07:05:02
问题 I'm trying to figure out, if it is possible send using Windows.Media.SpeechRecognition; args.Result.Text as parameter from UWP to Console application. For example by following scenario I'm sending TextToSpeech(args.Result.Text); with args.Result.Text; value, where using Windows.Media.SpeechSynthesis; text-to-speech pronounces the recognition result each time when args.Result.Text; appears. textBlock2.Text = args.Result.Text; also displays result: private async void

UWP: DataTemplateSelector and SelectedItem

与世无争的帅哥 提交于 2019-12-29 06:29:14
问题 How can I change the DataTemplate for the SelectedItem of ListView in UWP project? I'm trying to use the DataTemplateSelector but the problem is that SelectTemplateCore is called only one time. This what I have tried: MyTemplateSelector class public class MyTemplateSelector : DataTemplateSelector { public DataTemplate DefaultTemplate { get; set; } public DataTemplate SelectedItemTemplate { get; set; } protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)

UWP: Detect app gaining/losing focus

流过昼夜 提交于 2019-12-29 06:17:34
问题 I want to be able to prevent the screen saver from triggering while my app is in use by using the DisplayRequest class, but I only want to do this while it's the active app. If the user switches to another window/app then I want to act like a good citizen and allow the screensaver again. I can't see an obvious way to detect when a UWP app gets/loses focus (or is activated/deactivated) and a quick search around doesn't offer any insights. Can anyone point me in the right direction? 回答1: You

Could not load file or assembly 'System.Private.CoreLib…'

岁酱吖の 提交于 2019-12-28 19:28:20
问题 I have a Xamarin.Forms app which targets .net standard 1.4. On the UWP app which has minimum version 14393 (and targets 16299) I get the following exception from the Microsoft Store (though on my computer it runs fine even from the appxbundle file): Note the main points: The error occurs on Xamarin.Forms.Forms.Init(e); in OnLaunched . The error itself is Could not load file or assembly 'System.Private.CoreLib...' . System.IO.FileNotFoundException: Could not load file or assembly 'System

Windows Universal App Fullscreen Button

放肆的年华 提交于 2019-12-28 05:52:10
问题 Some Apps in the Windows Store have a Fullscreen button additional to the minimize, maximize and close button in the Titlebar. This button looks similar to the exit Fullscreen button that every App has in the Titlebar if the Fullscreen is active. Is that a system control and if how can I use it in my C# Universal App? 回答1: You'll have to use the Window.SetTitleBar method to achieve your desired behavior. Therefore, you'll need to accomplish a few steps: First, enable the view to extend into

[UWP]使用GetAlphaMask制作阴影

只谈情不闲聊 提交于 2019-12-27 07:42:25
1. 前言 最近常常接触到GetAlphaMask,所以想写这篇文章介绍下GetAlphaMask怎么使用。其实GetAlphaMask的使用场景十分有限,Github上能搜到的内容都是用来配合DropShadow的,所以这篇文章也以介绍DropShadow为主。 2. 合成阴影 先介绍一下合成阴影。Compositor.CreateDropShadow()可以创建一个DropShadow,将这个DropShadowDropShadow赋值到SpriteVisual的Shadow属性,然后使用ElementCompositionPreview.SetElementChildVisual 将这个SpriteVisual设置到某个UIElement的可视化层里,再将这个UIElement放到需要阴影的元素后面,这样基本的合成阴影就完成了。 具体代码如下: <Grid VerticalAlignment="Center" HorizontalAlignment="Center"> <Grid x:Name="BackgroundGrid"/> <Grid Background="Turquoise" x:Name="Host"> <TextBlock Text="I need shadow" Foreground="White" HorizontalAlignment="Center"

[UWP]CompositionLinearGradientBrush加BlendEffect

烂漫一生 提交于 2019-12-26 00:59:05
1. 什么是BlendEffect 上一篇文章介绍了CompositionLinearGradientBrush的基本用法, 这篇文章再结合BlendEffec介绍一些更复杂的玩法。 Microsoft.Graphics.Canvas.Effects 命名空间下的 BlendEffect 用于组合两张图片(分别是作为输入源的Background和Foreground),它包含多种模式,如下图所示: 其中最简单的是 Screen 模式,它的计算公式如下 看起来有点复杂, 我的理解是它相当于色轮中Background和Foreground之间拉直线,在直线的中间点的颜色,如下面这张图,红色和蓝色组合成为紫色: 2. 组合CompositionBrush并使用BlendEffect 许多 CompositionBrushes 使用其他 CompositionBrushes 作为输入。 例如,使用 SetSourceParameter 方法可以将其他 CompositionBrush 设为 CompositionEffectBrush 的输入。这是CompositionBrush最好玩的地方之一。下面的例子介绍了怎么使用BlendEffect创建CompositionBrush。 首先创建两个CompositionLinearGradientBrush: var