winrt-xaml

Why is calling await completing the parent Task prematurely?

孤街醉人 提交于 2019-11-29 16:57:29
I'm trying to create a control that exposes a DoLoading event that consumers can subscribe to in order to perform loading operations. For convenience, event handlers should be called from the UI thread allowing consumers to update the UI at will, but they will also be able to use async/await to perform long-running tasks without blocking the UI thread. For this, I have declared the following delegate: public delegate Task AsyncEventHandler<TEventArgs>(object sender, TEventArgs e); That allows consumers to subscribe to the event: public event AsyncEventHandler<bool> DoLoading; The idea is that

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

限于喜欢 提交于 2019-11-29 16:16:32
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 always returns null . Is there any workaround for this? Just figured this out. First create a helper class

ISupportIncrementalLoading inside ScrollViewer not supported?

拈花ヽ惹草 提交于 2019-11-29 15:59:59
I have a GridView with GridView.ItemsSource set to a collection that implements ISupportIncrementalLoading . By implementing this, I am aiming to improve load time and UI responsiveness by only loading items that are needed for display. The framework handles this for me and it works great. <GridView ItemsSource="{Binding Items}"> <GridView.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Text}"/> </DataTemplate> </GridView.ItemTemplate> </GridView> However , if I wrap the above XAML in a ScrollViewer like the following, the entire collection of Items loads as though the GridView is

Auto-complete box under a text box in Windows 8 / Metro UI

两盒软妹~` 提交于 2019-11-29 15:49:52
问题 I want to implement auto-complete on a textbox in a Windows 8 UI / Metro UI app using C#/XAML. At the moment, when the soft / touch keyboard shows, it obscures the auto-complete box. However, on the text box focus, Windows 8 automatically scrolls the entire view up and ensures the text box is in focus. In reality, all I want is the view to scroll up a little more (in fact, by the height of the auto-complete box). I realise I can intercept the Showing event of InputPane.GetForCurrentView() I

Windows 8 GridView - disabling item tap visualization

与世无争的帅哥 提交于 2019-11-29 14:34:11
问题 Is it possible to remove the tap effect on an item inside a gridview? 回答1: Yes, you need to modify the GridViewItem style in the ItemContainerStyle property. <GridView> <GridView.ItemContainerStyle> <Style TargetType="GridViewItem"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="GridViewItem"> <Border x:Name="OuterContainer"> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="Normal" /> <VisualState x:Name=

Global MediaElement that continues playing after navigating to other page

旧时模样 提交于 2019-11-29 10:22:42
问题 I am using a MediaElement to play music in my metro app. I want the Music keeps playing even if I navigate to another Page. In the following Thread that question was asked also: http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/241ba3b4-3e2a-4f9b-a704-87c7b1be7988/ I did what JimMan suggested 1) In App.xaml.cs Changed the control template of the root frame to include the MediaElement var rootFrame = new Frame(); rootFrame.Style = Resources["RootFrameStyle"] as Style;

Metro app - ListView - how to alternate background colour of ListViewItems

懵懂的女人 提交于 2019-11-29 10:19:44
In my Metro style app for Windows 8, I'm binding a Listview to an ObservableCollection and I would like the background color of each ListViewItem to alternate (white, gray, white, etc) <ListView x:Name="stopsListView" ItemsSource="{Binding}" > <ListView.ItemTemplate> <DataTemplate> <Grid Height="66" > <TextBlock Text="{Binding Title}" /> </Grid> </DataTemplate> </ListView.ItemTemplate> In WPF, this is done using a Style with Triggers - see this page . How do you accomplish this in a Metro app? Update: After the correct answer was given below, I went away and actually coded it. Here's some code

Metro App ListView SelectedItem Selected VisualState

橙三吉。 提交于 2019-11-29 08:52:11
I have a Metro App with a ListView that contains this definition: <ListView Grid.Row="0" x:Name="lv" CanDragItems="True" CanReorderItems="True" IsTabStop="True" SelectionMode="Extended" VirtualizingStackPanel.VirtualizationMode="Recycling"> <ListView.ItemTemplate> <DataTemplate> <Grid Width="{Binding ElementName=lv, Path=ActualWidth}"> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <Grid Grid.Row="0"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="65"/> </Grid.ColumnDefinitions> <TextBlock Grid.Column="0" x:Name="tb1" Foreground=

Dependency Property assigned with value binding does not work

▼魔方 西西 提交于 2019-11-29 07:29:08
问题 I have a usercontrol with a dependency property. public sealed partial class PenMenu : UserControl, INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } public bool ExpandCollapse { get { return false; } set { //code } } public static readonly DependencyProperty ExpandCollapseProperty = DependencyProperty

In WinRT api, how to accept user input in a dialog just like in Weather and Finance apps

筅森魡賤 提交于 2019-11-29 06:23:14
I am trying to display a dialog that allows the user to type a location, just like in the "add places" function of the Weather App on Windows 8. Windows.UI.Popups namespace does not have an appropriate control. It has the MessageDialog, but I don't think it can be customised to include a textbox in it. Would I need to use Windows.UI.XAML.Controls.Primitives.Popup control by any chance? There is no out of box control beyond Popup to handle this style of UI, the Callisto library uses this control quite a bit so it has a lot of good examples of it's usage. Edit: In fact now the Callisto library