winrt-xaml

Windows Store App Design-time DataContext

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-19 04:57:13
问题 I've been a XAML developer for years now but this one has stumped me. I've been sleeping badly so maybe I'm being dense. Just orientating myself with Windows Store apps, I noticed that the LayoutAwarePage has a DefaultViewModel these days, which is nice but I it gets set only at runtime. Really, we need a DataContext established during design time to see real fake data. So after failing with some more convoluted ViewModel hook-up code, I am down to this and it doesn't work: public sealed

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

Centering selected item in a scroll viewer

流过昼夜 提交于 2019-12-18 17:29:10
问题 I am trying to center a selected item in a ListView inside a ScrollViewer and struggling to calculate the vertical offset that I should be setting the ScrollViewer relative to the ListView. The following links set me on the right track, but because of the limitation of the WinRT API, was not able to use them: Make ListView.ScrollIntoView Scroll the Item into the Center of the ListView (C#) http://blogs.msdn.com/b/delay/archive/2009/04/19/fewer-gotchas-to-getcha-enhancing-the

Why can't I use {x:Bind {RelativeSource Self}} in a data template?

て烟熏妆下的殇ゞ 提交于 2019-12-18 17:00:41
问题 If I use {x:Bind {RelativeSource Self}} in a data template, I get the following error while compiling: Object reference not set to an instance of an object. The idea is to pass the templated object to a property like a command parameter. Here is an example MainPage.xaml : <Page x:Class="XBindTest5.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:XBindTest5" xmlns:d="http://schemas.microsoft

Playing a sound from a generated buffer in a Windows 8 app

爷,独闯天下 提交于 2019-12-18 12:35:03
问题 I'm porting some C# Windows Phone 7 apps over to Windows 8. The phone apps used an XNA SoundEffect to play arbitrary sounds from a buffer. In the simplest cases I'd just create a sine wave of the required duration and frequency. Both the duration and frequency can vary greatly, so I'd prefer not to rely on MediaElements (unless there is someway to shift the frequency of a base file, but that will only help me with the single frequency generation). What is the equivalent of an XNA

Go to visual states inside a Grid in code behind in Windows Store apps

吃可爱长大的小学妹 提交于 2019-12-18 09:16:34
问题 So my xaml code looks like this - <Grid x:Name="LayoutRoot"> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> I can't use the GoToVisualState behavior because I need to do some checks before running this animation. So I guess I will have to call something like GoToState or GoToElementState in code behind. However, ExtendedVisualStateManager doesn't seem to exist in WinRT . I tried using VisualStateManager.GetCustomVisualStateManager(this.LayoutRoot) but it

URI schemes supported in Windows 8 apps

烂漫一生 提交于 2019-12-18 06:54:51
问题 What are the URI schemes supported in Windows 8 apps? I have seen references to ms-appx: and ms-appdata: and some rare mentions of ms-resource: but I could not find any document that would be a list of the schemes (although I thought I have seen one in the past). I am wondering if URL.createObjectURL returns some other schemes, but I can't see a version of it for XAML apps. http://msdn.microsoft.com/en-us/library/windows/apps/Hh781215.aspx. Are there any other URI schemes supported in WinRT?

Binding the Content property of a ContentControl in WinRT

好久不见. 提交于 2019-12-18 06:06:36
问题 Let's say I have a Windows Store app (targeting Windows 8.1), and on a page there's a ContentControl that looks like this: <ContentControl> <ContentControl.Content> <TextBlock>Hello world</TextBlock> </ContentControl.Content> </ContentControl> This works absolutely fine, but if I try to set the content up as a resource, like this: <Page.Resources> <TextBlock x:Key="TestContent">Hello world</TextBlock> </Page.Resources> <ContentControl Content="{StaticResource TestContent}" /> Everything looks