Tag: windows runtime

容器如何知道孩子何时调用InvalidateArrange?

我正在尝试学习在WinRT XAML应用程序中创建自定义面板的基础知识。 我已经定义了一个附加的依赖属性,并且它按预期工作,除了我无法弄清楚如何获取属性的子元素的回调来触发容器的排列或度量。 让孩子知道应该再次调用安排和测量的正确方法是什么? 在我的WPF 4发行的书中,他们使用了FrameworkPropertyMetadataOptions.AffectsParentArrange,但在WinRT中似乎没有。 public class SimpleCanvas : Panel { #region Variables #region Left Property public static double GetLeft(UIElement element) { if (element == null) { throw new ArgumentNullException(“element”); } object value = element.GetValue(LeftProperty); Type valueType = value.GetType(); return Convert.ToDouble(value); } public static void SetLeft(UIElement element, double value) { if (element == null) […]

我可以在WinRT Metro Style Applications for Windows 8上使用我现有的.Net 4.0类库

我刚刚开始深入研究Metro Style应用程序开发,我意识到当我查看应用程序的属性时,没有针对性的框架。 那么,我可以在WinRT Metro Stype Applications for Windows 8上使用我现有的.Net 4.0类库(或以前的类库)吗? 例如,我想获得Autofac并使用它,但我不确定它是否合适。 编辑 我认为它实际上是针对.Net Framework Core 4.5。

以编程方式绑定ItemsSource

c#代码中的等价物是什么? … 我已经尝试了以下代码,但它似乎不起作用…… Binding b = new Binding(); b.Path = new PropertyPath(“taskItems”); DependencyProperty dp = DependencyProperty.Register(“itemsSource”, typeof(object), typeof(object), null); BindingOperations.SetBinding(taskItemListView, dp, b); 编辑 : 基于@ sa_ddam213的答案,这有效: Binding dataContextBinding = new Binding(); dataContextBinding.Path = new PropertyPath(“SelectedItem”); dataContextBinding.Source = itemListView; BindingOperations.SetBinding(taskItemListView, ListView.DataContextProperty, dataContextBinding ); Binding sourceBinding = new Binding(); sourceBinding.Path = new PropertyPath(“taskItems”); BindingOperations.SetBinding(taskItemListView, ListView.ItemsSourceProperty, sourceBinding );

如何在Windows Phone Runtime中向Clipboard添加文本?

以前在Windows Phone 8中我们可以使用Clipboard来共享文本。 它在Windows 8中受支持, Clipboard.SetContent(dataPackage); 但我发现Windows Phone Runtime不支持它 。 难道不再可能,或者还有其他办法吗?

无法在SQLite Net Platform WinRT中加载DLL的’sqlite3′

我正在使用Xamarin.Forms开发本机应用程序。 但我现在面临的问题与Xamarin无关。 我添加了新的Windows Phone项目 right-click > Add > New Project -> Windows Phone Apps -> Blank App(Windows Phone). 在我在Visual Studio premium 2013中的现有Xamarin项目中。我使用sqlitenet pcl进行数据库连接。 我的项目中有以下代码。 public ISQLitePlatform CreateSqlitePlatformInterface() { return new SQLitePlatformWinRT(); } 当它在行上面执行时,它会抛出exception An exception of type ‘System.DllNotFoundException’ occurred in SQLite.Net.Platform.WinRT.DLL but was not handled in user code Additional information: Unable to load DLL ‘sqlite3’: […]

如何使用WinRT打开打包文件

我试图弄清楚如何将一些解析xml文件的.Net代码移植到WinRT。 到目前为止,借助给定的System.Uri无法转换为Windows.Foundation.Uri ,我有以下代码。 不过,在我创建Uri之后,我立即陷入困境: static readonly Uri ResourcesBase = new Uri(@”ms-resource://MyAssembly/”); public override async void Load() { Uri uri = new Uri(ResourcesBase, filePath); // filePath = “Data//world.xml”; XmlLoadSettings settings = new XmlLoadSettings() { ValidateOnParse = false }; XmlDocument xmlDoc = await XmlDocument.LoadFromUriAsync(uri, settings); foreach (IXmlNode xmlNode in xmlDoc.ChildNodes) { ProcessNode(xmlNode); } } 当我尝试调用XmlDocument.LoadFromUriAsyn(uri)时,我得到一个未处理的exception: ArgumentException未被用户代码处理 – […]

在异步方法中显示错误消息的更好方法

我们不能在catch块中使用await关键字这一事实使得在WinRT中显示来自异步方法的错误消息非常尴尬,因为MessageDialog API是异步的。 理想情况下,我希望能够写下这个: private async Task DoSomethingAsync() { try { // Some code that can throw an exception … } catch (Exception ex) { var dialog = new MessageDialog(“Something went wrong!”); await dialog.ShowAsync(); } } 但相反,我必须这样写: private async Task DoSomethingAsync() { bool error = false; try { // Some code that can throw an exception […]

Metro UI:我正在切换xaml但图片没有加载

我有一个多xaml地铁应用程序。 我想通过按钮点击在xaml之间切换。 private void Button_Click_1(object sender, RoutedEventArgs e) { Window.Current.Content = new BlankPage1(); this.InitializeComponent(); } private void Button_Click_2(object sender, RoutedEventArgs e) { Window.Current.Content = new Sudoku.sudoku(); Window.Current.Activate(); } private void Button_Click_3(object sender, RoutedEventArgs e) { TextTwist.text_twist ob= new TextTwist.text_twist(); ob.InitializeComponent(); Window.Current.Content = ob; } 这是具有按钮的主xaml的逻辑代码。 现在,当我单击button1(/ button2 / button3)时,屏幕上会显示相应的xaml,但不会加载相关的图像。 它们在设计师中完全可见。 请帮帮我。 这是一个xaml片段 相关图像是网格背景图像,按钮图像等。

在Windows 8应用程序中使用SSL证书编程

我需要帮助: 我们的后端由自签名证书担保。 让我们称之为:OurMegaCoolCertificate.cer 因此,我们使用certmgr.msc将此证书导入我们的开发人员计算机。 现在我们可以使用以下代码从后端检索数据: async public static Task getData(string Id, string Type) { String url = “https://BACKEND/API/?Id=” + Id + “&Type=” + Type; HttpClientHandler aHandler = new HttpClientHandler(); aHandler.ClientCertificateOptions = ClientCertificateOption.Automatic; HttpClient aClient = new HttpClient(aHandler); aClient.DefaultRequestHeaders.ExpectContinue = false; aClient.DefaultRequestHeaders.MaxForwards = 3; Uri requestUri = new Uri(url); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri); //request.Headers.ExpectContinue […]

是否可以制作WinRT服务

由于WinRT具有独特的function,我想知道是否要制作针对WinRT的Windows服务? 如果不可能,是否可以使用不可见的WinRT / Metro应用程序? 非常感谢。