windows-runtime

WinRT 8.1 Phone - ListView reordering

ε祈祈猫儿з 提交于 2019-12-19 08:26:45
问题 I need to create a reorderable ListView in a Windows Phone 8.1 app created using WinRT. The XAML is the following (it binds to an ObservableDictionary in the codebehind): <Grid Margin="24"> <ListView x:Name="MainListView" CanDragItems="True" CanReorderItems="True" AllowDrop="True" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" > <ListView.ItemTemplate> <DataTemplate> <Border Padding="24" Margin="16" Background="CadetBlue"> <TextBlock Text="{Binding}" /> </Border> </DataTemplate> <

How to close Message Dialog programmatically

a 夏天 提交于 2019-12-19 08:01:22
问题 I am trying to close a MessageDialog in my WinRT App. I have noticed if I attempt to show two message dialogs at once, I get an UnauthorizedAccessException. To avoid this, I want to close the existing message dialog if it is open. I use this to show the dialog: MessageDialog md = new MessageDialog(" "); private void MessageBox(string s) { Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { md.Content = s; //CLOSE HERE md.ShowAsync(); } ); } How do I close it? 回答1: instead of trying to

How to change TextBox placeholder text color for a specific element, not global

醉酒当歌 提交于 2019-12-19 06:46:36
问题 MSDN lists the styles and templates for the TextBox class here. I can override these theme resources by creating a ResourceDictionary in App.xaml like this: <Application.Resources> <ResourceDictionary> <ResourceDictionary.ThemeDictionaries> <ResourceDictionary x:Key="Default"> <SolidColorBrush x:Key="TextBoxPlaceholderTextThemeBrush" Color="Yellow"/> </ResourceDictionary> </ResourceDictionary.ThemeDictionaries> </ResourceDictionary> </Application.Resources> but this will affect every TextBox

Unit Testing Windows 8 Store App UI (Xaml Controls)

时光总嘲笑我的痴心妄想 提交于 2019-12-19 06:03:12
问题 I've been creating a Windows Store App but I have thread problems testing a method which creates a Grid (Which is a XAML Control). I've tried to test using NUnit and MSTest. The test method is: [TestMethod] public void CreateThumbnail_EmptyLayout_ReturnsEmptyGrid() { Layout l = new Layout(); ThumbnailCreator creator = new ThumbnailCreator(); Grid grid = creator.CreateThumbnail(l, 192, 120); int count = grid.Children.Count; Assert.AreEqual(count, 0); } And the creator.CreateThumbnail (The

custom cursor in metro app

左心房为你撑大大i 提交于 2019-12-19 04:20:07
问题 I am developing a paint like application. I want to change cursor at some instance. So, how can I use the custom cursor in metro app ? I have found this Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Custom, uint id); In above method, there is one enum for "Custom" cursor and the second argument is for resource ID. So how can I get that ? 回答1: The basic route to doing this: Create your custom cursor and package it in a .res using a C++

Zoom Out Image to fit ScrollViewer Dimensions

谁说我不能喝 提交于 2019-12-19 04:05:18
问题 I have a little issue with zooming accordingly an image. I have an Image in my XAML, with a ScrollViewer attached so it can be zoomed. Like this : <ScrollViewer x:Name="ImageScrollViewer"> <Image x:Name="ImagePanel" Stretch="Uniform" VerticalAlignment="Center" HorizontalAlignment="Center"/> </ScrollViewer> What I'd like to do is that, in case the image is too big to fit the image control and needs to be zoomed out (only in this case), I'd like to programatically set the ZoomFactor of the

Programmatically scroll controls into view when virtual keyboard opens

为君一笑 提交于 2019-12-19 03:59:11
问题 I have a page with a vertical set of textboxes. If one of them is focused, all of them should be visible, even if the onscreen keyboard is displayed. There are just enough of them that all of them fit in the available space above the keyboard. When the bottom textbox is focused, the page gets automatically scrolled up so that all of them are visible, but if the top textbox is focused, the onscreen keyboard covers the bottom one. This is a simplified example of my page: <Grid Background="

How to disable selection a single item in a GridView

时光怂恿深爱的人放手 提交于 2019-12-19 03:09:23
问题 How do you disable the selection single item from a GridView? I have a GridView with it's ItemsSource bound to an IEnumerable<SampleDataItem>. I'd like to be able to programmatically not allow the selection of some items in the list while allowing selection of the others. 回答1: While I haven't done this, you should be able to use an ItemContainerStyleSelector on the GridView, the method gives you the container (GridViewItem) and the item you're binding to. From there you can set the IsEnabled

Selected Items using MVVM in WinRT

别说谁变了你拦得住时间么 提交于 2019-12-18 20:48:07
问题 I'm struggling to find a way to bind the SelectedItems property in a ListView to the view model. Previously I used this: http://www.codeproject.com/Articles/412417/Managing-Multiple-selection-in-View-Model-NET-Metr which no longer works in the RTM release. Any help is much appreciated! Thanks in advance :) 回答1: You could look at the ListViewExtensions.BindableSelection from the WinRT XAML Toolkit on CodePlex. 回答2: Turns out binding to the attached property was failing because the type of the

Yet another System.Runtime.InteropServices error

落花浮王杯 提交于 2019-12-18 19:31:27
问题 Every project we have with MongoDB will, at one point of another, have a problem with the System.Runtime.InteropServices library that doesn't load. This time the error is interesting: The outer exception can't find the version 4.3.0.0 of the lib. But the inner exception can't find version 4.0.0.0 Does anyone have an idea about that? More information about the problem: So, NuGet has 4.3.0.0 installed <?xml version="1.0" encoding="utf-8"?> <packages> <package id="System.Runtime" version="4.3.0"