我希望能够通过使用DisplayRequest类来阻止屏幕保护程序在我的应用程序使用时触发,但我只想在活动应用程序时执行此操作.如果用户切换到另一个窗口/应用程序,那么我想像一个好公民,并再次允许屏幕保护程序.
我无法看到一种明显的方法来检测UWP应用何时获得/失去焦点(或被激活/停用)并且快速搜索并不能提供任何见解.谁能指出我正确的方向?
假设我有一个Windows应用商店应用(针对Windows 8.1),并且在页面上有一个ContentControl,如下所示:
<ContentControl>
<ContentControl.Content>
<TextBlock>Hello world</TextBlock>
</ContentControl.Content>
</ContentControl>
Run Code Online (Sandbox Code Playgroud)
这工作绝对正常,但如果我尝试将内容设置为资源,如下所示:
<Page.Resources>
<TextBlock x:Key="TestContent">Hello world</TextBlock>
</Page.Resources>
<ContentControl Content="{StaticResource TestContent}" />
Run Code Online (Sandbox Code Playgroud)
设计器中的一切看起来都很棒,但是我在运行时遇到以下错误:
无法分配给属性'Windows.UI.Xaml.Controls.ContentControl.Content'
我已经尝试在各个地方定义资源(app.xaml,单独的资源文件等),但每次都会得到相同的错误.
所以,我有一些问题:
使用触摸触发ListView项目的拖放操作时,似乎WinRT(Windows 8/8.1)和UWP(Windows 10)应用程序之间的行为已更改.
在WinRT中,向左或向右"撕开"项目会导致它被分离,从而启动拖动行为.在UWP中,用户必须轻敲并暂停一个项目,然后移动它以启动拖动动作.
我的问题是:有没有办法恢复/实现旧的WinRT风格的行为?新的方式不是很明显,在有限的用户测试中,我没有看到一个人在没有向他们解释的情况下解决问题.
作为一个简单的例子,下面的XAML适用于WinRT和UWP,但是基于触摸的交互在WinRT中很容易被发现.
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<ListView AllowDrop="True" CanReorderItems="True">
<ListView.Items>
<x:String>Item 1</x:String>
<x:String>Item 2</x:String>
<x:String>Item 3</x:String>
<x:String>Item 4</x:String>
<x:String>Item 5</x:String>
</ListView.Items>
</ListView>
</Grid>
Run Code Online (Sandbox Code Playgroud) 在经典发布管道中,可以添加其他管道作为工件资源 - 这些可以是触发器,也可以只是引用。然后,您可以引用有关它们的信息,例如使用$(Release.Artifacts.ARTIFACTNAME.BuildId).
您现在可以在多阶段 yaml 管道中执行类似的操作:
resources:
pipelines:
- pipeline: MyBuild
source: My build pipeline name
trigger:
branches:
- master
steps:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: Write-Host Referenced pipeline build id is: ???
Run Code Online (Sandbox Code Playgroud)
但是根据上面的 PowerShell 步骤,我找不到一种方法来获取以这种方式关联的资源的构建 ID,而且我还无法在文档中找到任何内容。
我所做的一些绝望的尝试是:
resources:
pipelines:
- pipeline: MyBuild
source: My build pipeline name
trigger:
branches:
- master
steps:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: Write-Host Referenced pipeline build id is: ???
Run Code Online (Sandbox Code Playgroud)
有谁知道如何做到这一点?
yaml azure-devops azure-pipelines azure-pipelines-release-pipeline
uwp ×2
xaml ×2
azure-devops ×1
azure-pipelines-release-pipeline ×1
c# ×1
listview ×1
winrt-xaml ×1
yaml ×1