Tag: uwp

如何更改Pivot中的PivotHeaderItem的样式

我在UWP中查看了将PivotItemHeader样式应用于PivotItem,但我无法将这些建议应用于我的代码。 我正在尝试根据设备是桌面还是移动来更改数据透视表中的PivotHeaderItem的样式。 我的资源字典中有2个显式样式。 我的MainPage.xaml是: I don’t know what to put here —> I don’t know what to put here —> 我试过把代码: 在Pivot代码的不同部分,但我只收到错误。 如果我从资源字典中删除其中一个样式并将其他样式更改为隐式(删除x:Key),则样式应用正确并且我没有收到任何错误。 简而言之,我认为我的问题是我不知道如何x:命名一个PivotHeaderItem。

LiveSDK 5.6.3无法在UWP商店应用程序中运行

我有一个针对Windows 10的通用Windowsapp store应用。在以Windows 8.1为目标的应用的早期版本中,我使用LiveSDK( 此处为5.6版本 )使用LiveAuthClient从用户的MS Live帐户访问数据。 在新版本的应用程序中,我想我会使用最新版本的LiveSDK(这里有5.6.3作为nuget包提供 )但是当我安装nuget包时,我无法访问Microsoft.Live命名空间。 例如,以下声明: using Microsoft.Live; 产生错误”The type or namespace ‘Live’ does not exist in the namespace ‘Microsoft'” 这个包裹坏了还是我错过了一些明显的东西? 我希望这个工作就像使用5.6版本的LiveSDK一样。 似乎LiveSDK的文档都指向有关OneDrive api的信息,所以它让我想知道sdk的目的是否已经改变。 我很困惑……最新版本的LiveSDK(具有LiveAuthClient )是什么?我在哪里可以找到它?

如何更改UWP的复选框背景?

我无法使用以下代码更改复选框的背景,但它适用于Windowsapp store应用(Windows 8.1)。 我想知道如何让它适用于UWP? this.checkBox.Background = new SolidColorBrush(Windows.UI.Colors.Yellow); this.checkBox.Foreground = new SolidColorBrush(Windows.UI.Colors.Blue);

parse.com:SerializationException使用“__type”属性反序列化JSON对象

我正在开发一个Windows 10 UWP应用程序,似乎无法摆脱这个错误:“mscorlib.ni.dll中发生类型’System.Runtime.Serialization.SerializationException’的例外,但未在用户代码中处理” 我正在使用Rest API从Parse上的数据存储中检索值并实例化对象。 这是我class级的样子 public class ImageTest { public class Image { public string __type { get; set; } public string name { get; set; } public string url { get; set; } } public class Result { public string createdAt { get; set; } public Image image { get; set; } public […]

在应用程序的第二次运行时访问文件被拒绝

当我尝试使用代码访问SD卡上的文件时,我遇到了一个奇怪的问题: var path = @”D:\Test\test.txt”; try { StorageFile file = await StorageFile.GetFileFromPathAsync(path); } catch (Exception ex) { Debug.WriteLine($”File access failed due to {ex.Message}”); } path = @”Test\test.txt”; StorageFile file2 = await (await KnownFolders.RemovableDevices.GetFoldersAsync()).FirstOrDefault().GetFileAsync(path); 该文件在SD卡上,我已经声明了RemovableStoragefunction,并添加了FileTypeAssociation 。 我可以在第一次调试应用程序时获取该文件,但在第二次运行时,我获得了第一个StorageFile的 UnauthorizedException 。 令人惊讶的是第二次尝试通过RemovableStorage获取文件每次都有效。 如果我只重新启动手机并再次调试应用程序 – 它将再次工作,但仍然只是第一次。 StorageFile.GetFileFromPathAsync()以某种方式限制访问文件? 我错过了什么吗? 更新: 看起来像最新版本的模拟器10856我在每次运行时都会遇到exception,这可能意味着无法通过完整路径访问文件。

使用P / Invoke从C#编组“EGLRenderResolutionScaleProperty”到ANGLE

我正在尝试使用P / Invoke让ANGLE在C#中工作。 基本上,我正在创建一个简单的2D表面,然后将其传递给skia(使用SkiaSharp)。 一切都工作,所有这一切,但我有一个问题编组PropertySet到非托管代码。 这个位工作正常: // the properties var props = new PropertySet(); props.Add(“EGLNativeWindowTypeProperty”, swapChainPanel); // the surface attributes int[] surfaceAttrs = { EGL_ANGLE_SURFACE_RENDER_TO_BACK_BUFFER, EGL_TRUE, EGL_NONE }; // create the surface surface = eglCreateWindowSurface(eglDisplay, eglConfig, props, surfaceAttrs); 我的导入如下: [DllImport(“libEGL.dll”)] public static extern IntPtr eglCreateWindowSurface( IntPtr dpy, IntPtr config, [MarshalAs(UnmanagedType.IInspectable)] object win, int[] attrib_list); 当我尝试为高分辨率屏幕设置缩放时,问题就出现了。 […]

在UWP.Access中保存图像时拒绝访问被拒绝。 (来自HRESULT的exception:0x80070005(E_ACCESSDENIED))

我正在使用Windows 10 SDK上的通用Windows应用程序在图像中识别的面上绘制矩形。 我正在使用Win2D编辑图片并在其上绘制矩形。 我能够从图片库中读取文件,但是当我尝试在编辑后保存图像时,会出现以下错误: 访问被拒绝。 (来自HRESULT的exception:0x80070005(E_ACCESSDENIED)) 以下是我用于在图像上绘制矩形的方法: private async void DrawRect() { CanvasDevice device = CanvasDevice.GetSharedDevice(); CanvasBitmap bitmap = null; CanvasRenderTarget offscreen = null; Windows.Storage.StorageFile photofile = await KnownFolders.PicturesLibrary.GetFileAsync(“image.jpg”); if(photofile != null) { using (var stream = await photofile.OpenReadAsync()) { bitmap = await CanvasBitmap.LoadAsync(device, stream); } } if(bitmap != null) { offscreen = new […]

来自MemoryStream的UWP BitmapImage SetSource挂起

在我的UWP应用程序中,我以byte []的forms将图像存储在SQLite数据库中。 然后当我从db中检索我的对象时,我将它们绑定到具有Image控件的GridView数据模板。 由于我无法将Image的Source直接绑定到数组,因此我在对象的类中创建了一个BitmapImage属性,以将Image控件绑定到: public BitmapImage Icon { get { using (var stream = new MemoryStream(icon)) { stream.Seek(0, SeekOrigin.Begin); var img = new BitmapImage(); img.SetSource(stream.AsRandomAccessStream()); return img; } } } 问题是,我的应用程序挂在img.SetSource行上。 经过一些实验,我发现第二个MemoryStream可以解决这个问题: public BitmapImage Icon { get { using (var stream = new MemoryStream(icon)) { stream.Seek(0, SeekOrigin.Begin); var s2 = new MemoryStream(); stream.CopyTo(s2); s2.Position = […]

在UserControl中捕获Esc键

我想使用UserControl创建一个Custom Popup UserControl ,因为这是UWP应用程序,我想在用户按下键盘上的ESC时隐藏Popup窗口。 我尝试覆盖UserControl OnKeyDown方法,但是当我在键盘上按ESC时,此方法从未执行过。 protected override void OnKeyDown(KeyRoutedEventArgs e) { if (e.Key == VirtualKey.Escape) { this.Visibility = Visibility.Colapse; } }

UWP – 防止NavigationViewItemHeader被剪裁

我正在编写一个UWP应用程序,其中包含一个包含NavigationViewItemHeader : (等等) 但是,当我折叠视图时,标题会被剪切: 我该怎么做才能防止这种情况发生?