我想使用 UWP 的新功能 -> x:Bind。为此,我的所有页面都需要具有 ViewModel 属性(如教程中所述)。为了避免代码重复,我建立了如下基类:
public abstract class BasePage<TBaseVM> : Page, where TBaseVM : BaseVM
{
public TBaseVM VM { get; private set; }
protected BasePage()
{
DataContextChanged += (s, e) => VM = e.NewValue as TBaseVM;
}
}
Run Code Online (Sandbox Code Playgroud)
如您所见,此 BasePage 类包含名为“VM”的属性,并且该属性的类型为 BaseVM。因此,我不需要在每个派生类上定义 VM 属性。
然后我创建了在 xaml 中定义的派生页面“MainPage”,如下所示:
<pages:BasePage
x:Class="Realarm.View.Pages.MainPage"
x:TypeArguments="viewModel:MainVM">
Run Code Online (Sandbox Code Playgroud)
通过这样做,即使是 Resharper 的 Intellisense 也为我提供了 MainPage.xaml 中“MainVM”的属性,因此可以这样写:
<ListView ItemsSource="{x:Bind VM.AlarmsVM}">
Run Code Online (Sandbox Code Playgroud)
不幸的是,当我尝试构建项目时,在 MainPage.gics 中出现错误:
严重性代码描述项目文件行错误 CS0305 使用通用类型“BasePage”需要 1 个类型参数 Realarm D:...\Realarm\obj\x86\Debug\View\Pages\MainPage.gics 13
有什么帮助吗?
我有一个Cortana XML文件,我需要输入一个数字.我该怎么做才能确保将其转换为数字?
<Command Name="AddMoney">
<Example> Add 10 dollars </Example>
<ListenFor> add {amount} {currency} </ListenFor>
<Feedback> Adding some money </Feedback>
<Navigate/>
</Command>
<PhraseList Label="currency">
<item>dollar</item>
<item>euro</item>
<item>pound</item>
</PhraseList>
<PhraseList Label="amount">
</PhraseList>
Run Code Online (Sandbox Code Playgroud) 是否可以使用C#代码在UWP应用程序中获取当前的Windows 10主题颜色?
我找到了Application.RequestedTheme 属性,但它只告诉我是否使用了暗och灯主题,而不是实际的颜色.
我见过XAML标记,它引用了主题颜色,但想知道RGB值.
我已经按照Microsoft在Microsoft Holographic - Academy教程中的多个项目中列出的确切步骤进行了操作.我完成了所有这些工作,所有这些工作都很好,从创建到导出和测试.这是使用Unity3D/C#,它被编译成Visual Studio Solution(sln)文件.
在完成这些之后,我继续构建我自己的应用程序 - 它也构建得很好.没问题!
现在,当我尝试构建时 - 我得到一个奇怪的错误,无法找到c-Sharp.firstpass文件(我所了解的导出/交叉编译的dll).
现在,即使是成功建造的项目也不会再建造.
我将在下面粘贴确切的错误.
我尝试过的事情:
似乎有一个引用问题 - 所以我也没有引用/引用上面提到的文件.
感谢您的帮助.为了清楚起见,这是一个为Microsoft Hololens开发的Windows 10 Universal应用程序.但是,在这种情况下,设备本身似乎与构建过程几乎没有任何关系,除了定位它.
最好,
Addyarb
错误:
命令""D:\ Development\Hololens Builds\PlanetApp\Unity\Tools\SerializationWeaver\SerializationWeaver.exe""D:\ Development\Hololens Projects\Planetarium\UWP\Assembly-CSharp-firstpass\bin\x86\Release\Unprocessed\Assembly-CSharp-firstpass.dll"-pdb -verbose -unity-engine ="D:\ Development\Hololens Builds\PlanetApp\Planetarium\Unprocessed\UnityEngine.dll"-unity-networking = D:\ Development\Hololens Builds\PlanetApp\Planetarium\Unprocessed\UnityEngine.Networking.dll"D:\ Development\Hololens Projects\Planetarium\UWP\Assembly-CSharp-firstpass\obj\x86\Release\x86\Release""退出代码1. Assembly-CSharp- firstpass D:\ Development\Hololens Projects\Planetarium\UWP\Assembly-CSharp-firstpass\Assembly-CSharp-firstpass.csproj 180
无法找到元数据文件'D:\ Development\Hololens Projects\Planetarium\UWP\Assembly-CSharp-firstpass\bin\x86\Release\Assembly-CSharp-firstpass.dll'Assembly-CSharp D:\ Development\Hololens Projects \天文馆\ UWP \大会-CSHARP\CSC
无法找到元数据文件'D:\ Development\Hololens Projects\Planetarium\UWP\Assembly-CSharp\bin\x86\Release\Assembly-CSharp.dll'Planetarium D:\ Development\Hololens Builds\PlanetApp\Planetarium\CSC
出于某种原因,当我在VS2015 Update 2 RTM中生成UWP应用程序的新版本时,其先前版本已经存储了很长一段时间,新生成的.appxupload包不包含应用程序的调试/符号数据(.appxsym)文件.
此外,当我尝试将上述.appxupload上传到商店时,发生以下错误:
提交失败,错误代码为1300.有关错误的更多信息,请点击此处.
上面的链接"here"有一个简短的引用:
UWP应用程序
如果您要提交UWP应用程序,如果您的包文件不是Visual Studio为商店生成的.appxupload文件,则在预处理期间可能会看到错误.在创建应用程序包文件时,请确保按照打包适用于Windows 10的通用Windows应用程序中的步骤进行操作,并且只在提交的"包"页面上上载.appxupload文件,而不是appx或.appxbundle.
提交应用程序后可能会看到的另一个错误是错误1300.当一个或多个程序集(或整个程序包)已经预编译时,会发生这种错误.要解决此问题,请在Microsoft Visual Studio中重建应用程序包,然后提交新生成的包.
所以现在我被这个问题阻止了,无法更新应用程序.
有没有人有任何线索?
windows-store-apps win-universal-app windows-10 windows-10-mobile windows-10-universal
我正在使用Visual Studio 2015和Apache Cordova制作我的UWP应用。但是我的应用程序的任务栏图标看上去比旁边的所有其他应用程序小。
我的应用程序显示最右边的图标。如您所见,它比放置在其左侧的所有其他图标都要小(在所有四个侧面上都看起来像是填充版本)。
这是实际的Square44x44Logo.scale-100.png,如下图所示,我的图像中没有填充
我遵循了Apache Studio Cordova的Visual Studios项目模板,这是我的图标声明 config.xml
<platform name="windows">
<icon height="150" src="res/icons/windows/Square150x150Logo.scale-100.png" width="150" />
<icon height="360" src="res/icons/windows/Square150x150Logo.scale-240.png" width="360" />
<icon height="30" src="res/icons/windows/Square30x30Logo.scale-100.png" width="30" />
<icon height="310" src="res/icons/windows/Square310x310Logo.scale-100.png" width="310" />
<icon height="106" src="res/icons/windows/Square44x44Logo.scale-240.png" width="106" />
<icon height="70" src="res/icons/windows/Square70x70Logo.scale-100.png" width="70" />
<icon height="170" src="res/icons/windows/Square71x71Logo.scale-240.png" width="170" />
<icon height="50" src="res/icons/windows/StoreLogo.scale-100.png" width="50" />
<icon height="120" src="res/icons/windows/StoreLogo.scale-240.png" width="120" />
<icon height="150" src="res/icons/windows/Wide310x150Logo.scale-100.png" width="310" />
<icon height="360" src="res/icons/windows/Wide310x150Logo.scale-240.png" width="744" />
<icon height="44" src="res/icons/windows/Square44x44Logo.scale-100.png" width="44" />
<icon height="71" src="res/icons/windows/Square71x71Logo.scale-100.png" width="71" …Run Code Online (Sandbox Code Playgroud) 我想在屏幕右侧设置窗口的位置,类似于WPF.UWP有办法做到这一点吗?
我正在关注https://docs.microsoft.com/en-us/windows/uwp/launch-resume/create-and-register-a-background-task文档以创建一个后台任务,该任务将每15分钟运行一次并ping一项服务.
使用实现IBackgroundTask的公共密封类创建了一个Windows运行时组件项目
namespace PeriodicBackgroundTask
{
public sealed class FifteenMinutePeriodicTimer : IBackgroundTask
{
private static readonly FileLogWriter mWriteLogToFile = new FileLogWriter();
public FifteenMinutePeriodicTimer() { }
public void Run(IBackgroundTaskInstance taskInstance)
{
try
{
taskInstance.Canceled += new BackgroundTaskCanceledEventHandler(OnCanceled);
mDeferral = taskInstance.GetDeferral();
mWriteLogToFile.log("Starting periodic timer at " + DateTime.Now.ToString());
// Calling method to do a Post call to a service.
mWriteLogToFile.log("Finishing periodic timer at " + DateTime.Now.ToString());
}
catch (Exception ex)
{
mWriteLogToFile.log("Fifteen Minute periodic timer failed.", ex);
}
finally
{
// …Run Code Online (Sandbox Code Playgroud)我知道我可以使用Win32 API访问我自己的本地数据文件夹中的文件(例如,看到这个回答的问题),但我需要访问我的应用程序之外的文件(例如,从图片库)和我正在尝试的库use都基于Win32文件HANDLE和/或它们依赖于使用相对文件名.
由于获取图片库中的文件(或从拾取器返回文件/文件夹)的唯一方法是通过StorageFile对象,我如何重新使用现有代码?我是否必须将其重新编写为异步并依赖WinRT存储API?
我正在尝试从UWP app启动位于C:/ Program Files(x86)/ App中的exe。我怎样才能做到这一点。
我可以使用UWP的Windows桌面扩展名启动exe文件,添加“隐藏复制代码”
<Extensions>
<desktop:Extension Category="windows.fullTrustProcess" Executable="Assets\app.exe" />
</Extensions>
Run Code Online (Sandbox Code Playgroud)
到Package.appmanifest并调用它
await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();
Run Code Online (Sandbox Code Playgroud)
在主要班级。但是我需要将app.exe添加到项目的Assets目录中。
我的问题是exe文件是否位于其他目录中,如何在不完全添加exe文件的情况下启动它。
谢谢