winrt-xaml

How to detect ListView is scrolling up or down

て烟熏妆下的殇ゞ 提交于 2019-11-28 10:20:34
Is there a way to detect that ScrollViwer of ListView is in scrolling mode and stopped scrolling. In windows phone 8.1 ListView we can not get reference of the scrollviewer. Any one done it in windows phone 8.1 WinRT app? yasen Once the ListView is Loaded you can get the ScrollViewer like this: var sv = (ScrollViewer)VisualTreeHelper.GetChild(VisualTreeHelper.GetChild(this.ListV, 0), 0); Edit As Romasz suggested, once you get the ScrollViewer , you can use its ViewChanged event, to monitor when it is scrolling and when it stops. Also, here's the generic extension method that I use for

ISupportIncrementalLoading inside ScrollViewer not supported?

允我心安 提交于 2019-11-28 10:15:13
问题 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

How to access Parent's DataContext in Windows 8 store apps

左心房为你撑大大i 提交于 2019-11-28 10:02:58
This is a common situation in XAML based apps (WPF/Silverlight/WinRT). WPF related link -> WPF Databinding: How do I access the "parent" data context? RelativeSource with AncestorType , and Mode=FindAncestor usually comes to rescue in WPF. Both of these are missing in WinRT API. How to access the Parent's (may not be immediate one), DataContext ? (I am aware of TemplateBinding , and ElementBinding but both are not suitable mostly in DataTemplate). LMK I just had the same problem. Presumably this is common?? Here is a crude solution that works: Bind the Tag property of a top level element to

Listview selection display with no padding and no checkmark

时光毁灭记忆、已成空白 提交于 2019-11-28 08:47:41
I have this XAML to display a ListView in a C++/CX code. The ListView will be used as a selection menu. <ListView x:Name="itemsListView" ItemsSource="{Binding Source={StaticResource MenuDataSourceCVS}}" HorizontalAlignment="Stretch" Width="230" Margin="0,45,0,0" VerticalAlignment="Top" Grid.Row="1" SelectionChanged="itemsListView_SelectionChanged" SelectionMode="Single" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" FontFamily="Global User Interface"> <ListView.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" Height="40" Width="230"> <TextBlock Text="

How to design Metro UIs with fonts that look good on any resolution?

邮差的信 提交于 2019-11-28 08:27:25
问题 When one looks at the Guidelines for fonts, we see that fonts are specified in points. A point is 1/72 of an inch so it is an absolute measure: a 10 points character should show at the exact same absolute size on any monitor at any resolution. That would make sense to me as I want to be able to read text -at the same size- whether on a 10 in tablet or a 23 in monitor. In other words, I want my text to be readable on a tablet, but I do not want it to be too big on a monitor. On the other hand,

WinRT (Win 8) Store App XAML Bindings RelativeSourceMode FindAncestor missing?

隐身守侯 提交于 2019-11-28 07:37:15
does anybody know what the "new way" of FindAncestor in XAML bindings is? Looking at the RelativeSourceMode ( http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.data.relativesourcemode ) there are only options left for referencing self or the TemplatedParent. FindAncestor is gone. I'd like to know why and what are the typical solutions to the problems I fixed using FindAncestor. Best regards Gope Why it's missing? No idea, but I doubt there's an explanation other than "Microsoft did not have enough time to implement all the features in time". An easy work-around is to use

How do I get Local folder size in Windows 8.1 (winRT)

匆匆过客 提交于 2019-11-28 05:28:57
问题 I have an Windows 8.1 Store App. I am trying to find the Local Folder Size.?(e.g. 210 MB) I have an application which would download some of content into my local folder. I want to check the size of my local folder (such as how many MB are currently there). I have tried looking through MSDN and Google but haven't been able to find anything on it. Note : I have a folder and subfolder so not only files which is in local folder.. 回答1: You are able to access the LocalFolder via the

How to have DesignTime data in WinRT XAML?

谁说我不能喝 提交于 2019-11-28 05:07:15
How can I get DesignTime data in WinRT XAML so the designer shows sample data? Simple enough. Create a Model like this: public class Fruit { public string Name { get; set; } } Create a base ViewModel like this: public class BaseViewModel { public ObservableCollection<Fruit> Fruits { get; set; } } Create a real ViewModel like this: public class RealViewModel : BaseViewModel { public RealViewModel() { if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled) LoadData(); } public void LoadData() { // TODO: load from service } } Create a fake-data ViewModel like this: public class FakeViewModel

How do I de/serialize JSON in WinRT?

倾然丶 夕夏残阳落幕 提交于 2019-11-28 05:02:29
How do I take an object and convert it to a JSON string and then back into that object from a string, specifically, in WinRT for my Windows 8 Metro application? Like this: using System.IO; using System.Runtime.Serialization.Json; using System.Text; public static T Deserialize<T>(string json) { var _Bytes = Encoding.Unicode.GetBytes(json); using (MemoryStream _Stream = new MemoryStream(_Bytes)) { var _Serializer = new DataContractJsonSerializer(typeof(T)); return (T)_Serializer.ReadObject(_Stream); } } public static string Serialize(object instance) { using (MemoryStream _Stream = new

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

末鹿安然 提交于 2019-11-28 03:34:39
问题 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?