Tag: uwp

获得“元组元素名称的推断。 请使用语言版本7.1或更高版本通过其推断名称访问元素。“

我们将以下代码在我们的UWP应用程序中运行良好,直到今天我们将Visual Studio 2017更新到最新的15.3 。 private void Test() { var groups = new List<(Guid key, IList items)>(); var items = new List { (“a”, true), (“b”, false), (“c”, false) }; var group = (Guid.NewGuid(), items); groups.Add(group); } 输出窗口中没有错误消息 推断元组元素名称’items’。 请使用语言版本7.1或更高版本通过其推断名称访问元素。 知道为什么以及如何解决这个问题?

如何在windows 10 uwp中有效地使用WriteableBitmap.setpixel()?

我有一个场景 选择一个图像文件然后使用BitmapDecoder将源转换为WriteableBitmap并将image.source设置为WriteableBitmap。 现在,当用户点击图像时,我得到坐标,然后想要用特定颜色为该像素周围的整个区域着色。(就像绘画中的填充选项一样)。 我用的代码是 private void setPixelColors(int xCord, int yCord, int newColor) { Color color = bit.GetPixel(xCord, yCord); if (color.R <= 5 && color.G <= 5 && color.B <= 5 || newColor == ConvertColorToInt(color)) { //Debug.WriteLine("The color was black or same returning"); return; } setPixelColors(xCord + 1, yCord, newColor); setPixelColors(xCord, yCord + 1, newColor); setPixelColors(xCord […]

如何在webview中处理确认对话框? UWP windows 10 app C#

我正在通过c#开发uwp app(win 10) 我想把我的网站放在xaml webview元素中。 大多数function都是可行的。 但我无法处理确认对话框 例如 这是示例html和js代码 click me to confirm click me to alert function confirmBox(message) { if (confirm(message)) { alert(“yes”); } else { alert(“no”); } } 这是我的xaml代码 这是我的C#代码 webView1.ScriptNotify += webView1_ScriptNotify; webView1.NavigationCompleted += webView1_NavigationCompleted; async void webView1_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args) { await webView1.InvokeScriptAsync(“eval”, new string[] { “window.confirm = function(confirmMessage) { window.external.notify(‘typeConfirm:’ […]

启动时Windows 10 Universal app屏幕尺寸无法正常工作

我已经阅读了很多关于在启动时设置应用程序窗口大小的内容。 基本上,我的应用程序每次都会启动全屏。 我希望在启动时将其限制为预定义的大小。 然而,似乎没有任何工作。 这是我到目前为止所做的: 我提出以下内容: var desiredSize = new Size(400, 600); ApplicationView.GetForCurrentView().ExitFullScreenMode(); ApplicationView.GetForCurrentView().SetPreferredMinSize(desiredSize); ApplicationView.PreferredLaunchViewSize = desiredSize; ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize; 并且已经在MainPage.xaml.cs的构造函数中首先尝试了该代码段(这不起作用),然后就在上面 Window.Current.Activate(); 在App.xaml.cs中也没用。 基于一些阅读,我也尝试添加: ApplicationView.GetForCurrentView().TryResizeView(desiredSize); 在App.xaml.cs中的Window.Current.Activate之后和MainPage.xaml.cs中的构造函数的末尾。 我注意到在MainPage.xaml.cs中,我可以这样做: this.Width = 400; this.Height = 600; 这确实可以在窗口内正确调整MainPage框架的大小,但整个Window的大小保持不变。 我可以在启动后手动将窗口拖动到我想要的大小,但我想要它,所以只需每次都启动这个大小。 我错过了什么? 谢谢!

UWP VirtualKeyboard在简单文本框中显示NumericPin布局

我的应用程序中的不同视图中有多个文本框控件。 对于每个文本框,inputScope设置为default或AlphaNumeric。 在我打开ContentDialog并关闭它时,有些情况很好,即使我单击Windows任务栏键盘按钮,KeyboardLayout也会成为所有文本框的NumericPic布局。 NumericPic未在任何位置设置,已在所有代码中检查过。 有人知道这个吗? 或许是一个Windows问题? 检查了Lenovo Tablet,Windows 10 Home Single Language v 1607和Chuwi Tablet。 Scrren

C#UWP ScrollViewer改变Horizo​​ntalScrollBarVisibility

我有一个滚动查看器定义如下: 当我在后面的代码中更改属性Horizo​​ntalScrollBarVisibility时: svMain.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled; scrollviewer滚动到水平偏移0。 如何防止这种情况,并保留scrollviewer在此更改之前的水平偏移量?

绑定背景类的样式颜色

在我的应用程序中我有ColorToBrushConverter.cs,ColorItem.cs和一个包含一些颜色集合的框页,当用户点击任何颜色并返回到主页它保存到设置隔离存储然后我能够设置我的stackpanel任何元素背景从该颜色框页面中选择颜色。 但问题是我有一种样式,我想要颜色绑定,所以我们可以从c#中做到这一点,或者在下面的类中使用xaml中的颜色绑定。 ColorToBrushConverter.cs namespace CustomColorsPicker.Converters { public class ColorToBrushConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value != null) { return new SolidColorBrush((Color)(value)); } return null; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } } } ColorItem.cs namespace ColorBox […]

在FM无线电频率上前进和后退

我已经设计了一个后退按钮和一个带xaml的前进按钮。 当我单击后退按钮时,我的FM收音机实例应根据信号强度开始寻找低于射频的射频。

从课外获取SPI温度数据

我正在尝试编写一个“温度”类来处理通过SPI与我的RaspberryPi进行通信以读取一些温度数据。 目标是能够从我的Temperature类之外调用GetTemp()方法,这样我可以在我的程序的其余部分中随时使用温度数据。 我的代码设置如下: public sealed class StartupTask : IBackgroundTask { private BackgroundTaskDeferral deferral; public void Run(IBackgroundTaskInstance taskInstance) { deferral = taskInstance.GetDeferral(); Temperature t = new Temperature(); //Want to be able to make a call like this throughout the rest of my program to get the temperature data whenever its needed var data = t.GetTemp(); } […]

C#中的UWP递归文件搜索速度非常慢

我使用以下代码以递归方式搜索所选文件夹中的图像。 我在该文件夹中有超过120000张图像(是的,我是一名摄影师!)而且它非常慢,例如我必须在10分钟后停止它并且还没有完成。 相比之下,我的Python代码(解释!)在不到2分钟内完成相同的操作。 有没有办法让这个代码更有效率? 它工作正常,没关系,但只是非常缓慢…… public List _allFiles; public List ShuffledFiles; public int i = 0; public int ri = 0; public Boolean random = false; public int numfiles = 0; //Get the starting folder for recursive search private static async Task SelectFolderAsync() { var folderPicker = new Windows.Storage.Pickers.FolderPicker { SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop }; //Selects […]