Permalink
Browse files

work

  • Loading branch information...
1 parent a33a5e1 commit 9a504bfb20bc7acc101ee0fbcc092cdbaf2e6dfc @mikoskinen committed Nov 9, 2012
Showing with 3,819 additions and 0 deletions.
  1. +46 −0 WinRT-GridView-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems.sln
  2. +2 −0 ...-GridView-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems.sln.DotSettings.user
  3. +35 −0 WinRT-GridView-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/App.xaml
  4. +103 −0 WinRT-GridView-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/App.xaml.cs
  5. BIN ...T-GridView-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/Assets/DarkGray.png
  6. BIN ...-GridView-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/Assets/LightGray.png
  7. BIN WinRT-GridView-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/Assets/Logo.png
  8. BIN ...GridView-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/Assets/MediumGray.png
  9. BIN ...-GridView-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/Assets/SmallLogo.png
  10. BIN ...idView-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/Assets/SplashScreen.png
  11. BIN ...-GridView-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/Assets/StoreLogo.png
  12. +76 −0 ...idView-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/BadPerformancePage.xaml
  13. +35 −0 ...iew-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/BadPerformancePage.xaml.cs
  14. +55 −0 ...ridView-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/Common/BindableBase.cs
  15. +21 −0 ...-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/Common/BooleanNegationConverter.cs
  16. +32 −0 ...formance-Problems/WinRT-GridView-XAML-Performance-Problems/Common/BooleanToVisibilityConverter.cs
  17. +464 −0 ...View-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/Common/LayoutAwarePage.cs
  18. +12 −0 WinRT-GridView-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/Common/ReadMe.txt
  19. +210 −0 ...View-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/Common/RichTextColumns.cs
  20. +1,829 −0 ...iew-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/Common/StandardStyles.xaml
  21. +257 −0 ...ew-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/Common/SuspensionManager.cs
  22. +74 −0 ...-GridView-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/Data/VideoService.cs
  23. +82 −0 ...dView-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/GoodPerformancePage.xaml
  24. +59 −0 ...ew-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/GoodPerformancePage.xaml.cs
  25. +40 −0 ...GridView-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/MovieDetailsPage.xaml
  26. +32 −0 ...dView-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/MovieDetailsPage.xaml.cs
  27. +88 −0 WinRT-GridView-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/MoviesVm.cs
  28. +18 −0 ...GridView-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/MyTemplateSelector.cs
  29. +42 −0 ...-GridView-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/Package.appxmanifest
  30. +29 −0 ...iew-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems/Properties/AssemblyInfo.cs
  31. +178 −0 ...Problems/WinRT-GridView-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems.csproj
  32. BIN ...inRT-GridView-XAML-Performance-Problems/WinRT-GridView-XAML-Performance-Problems_TemporaryKey.pfx
@@ -0,0 +1,46 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinRT-GridView-XAML-Performance-Problems", "WinRT-GridView-XAML-Performance-Problems\WinRT-GridView-XAML-Performance-Problems.csproj", "{DD6D0CB1-CB71-4AAA-93C2-16087384A618}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|ARM = Debug|ARM
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
+ Release|ARM = Release|ARM
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {DD6D0CB1-CB71-4AAA-93C2-16087384A618}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {DD6D0CB1-CB71-4AAA-93C2-16087384A618}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DD6D0CB1-CB71-4AAA-93C2-16087384A618}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
+ {DD6D0CB1-CB71-4AAA-93C2-16087384A618}.Debug|ARM.ActiveCfg = Debug|ARM
+ {DD6D0CB1-CB71-4AAA-93C2-16087384A618}.Debug|ARM.Build.0 = Debug|ARM
+ {DD6D0CB1-CB71-4AAA-93C2-16087384A618}.Debug|ARM.Deploy.0 = Debug|ARM
+ {DD6D0CB1-CB71-4AAA-93C2-16087384A618}.Debug|x64.ActiveCfg = Debug|x64
+ {DD6D0CB1-CB71-4AAA-93C2-16087384A618}.Debug|x64.Build.0 = Debug|x64
+ {DD6D0CB1-CB71-4AAA-93C2-16087384A618}.Debug|x64.Deploy.0 = Debug|x64
+ {DD6D0CB1-CB71-4AAA-93C2-16087384A618}.Debug|x86.ActiveCfg = Debug|x86
+ {DD6D0CB1-CB71-4AAA-93C2-16087384A618}.Debug|x86.Build.0 = Debug|x86
+ {DD6D0CB1-CB71-4AAA-93C2-16087384A618}.Debug|x86.Deploy.0 = Debug|x86
+ {DD6D0CB1-CB71-4AAA-93C2-16087384A618}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {DD6D0CB1-CB71-4AAA-93C2-16087384A618}.Release|Any CPU.Build.0 = Release|Any CPU
+ {DD6D0CB1-CB71-4AAA-93C2-16087384A618}.Release|Any CPU.Deploy.0 = Release|Any CPU
+ {DD6D0CB1-CB71-4AAA-93C2-16087384A618}.Release|ARM.ActiveCfg = Release|ARM
+ {DD6D0CB1-CB71-4AAA-93C2-16087384A618}.Release|ARM.Build.0 = Release|ARM
+ {DD6D0CB1-CB71-4AAA-93C2-16087384A618}.Release|ARM.Deploy.0 = Release|ARM
+ {DD6D0CB1-CB71-4AAA-93C2-16087384A618}.Release|x64.ActiveCfg = Release|x64
+ {DD6D0CB1-CB71-4AAA-93C2-16087384A618}.Release|x64.Build.0 = Release|x64
+ {DD6D0CB1-CB71-4AAA-93C2-16087384A618}.Release|x64.Deploy.0 = Release|x64
+ {DD6D0CB1-CB71-4AAA-93C2-16087384A618}.Release|x86.ActiveCfg = Release|x86
+ {DD6D0CB1-CB71-4AAA-93C2-16087384A618}.Release|x86.Build.0 = Release|x86
+ {DD6D0CB1-CB71-4AAA-93C2-16087384A618}.Release|x86.Deploy.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
@@ -0,0 +1,2 @@
+<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
+ <s:Boolean x:Key="/Default/Environment/SearchAndNavigation/MergeOccurences/@EntryValue">False</s:Boolean></wpf:ResourceDictionary>
@@ -0,0 +1,35 @@
+<Application
+ x:Class="WinRT_GridView_XAML_Performance_Problems.App"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+
+ <Application.Resources>
+ <ResourceDictionary>
+ <ResourceDictionary.MergedDictionaries>
+ <ResourceDictionary Source="Common/StandardStyles.xaml"/>
+ </ResourceDictionary.MergedDictionaries>
+
+ <DataTemplate x:Key="MovieTemplate">
+ <Grid HorizontalAlignment="Left" Width="250" Height="250">
+ <Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}">
+ <Image Source="{Binding Cover}" Stretch="UniformToFill" AutomationProperties.Name="{Binding Title}"/>
+ </Border>
+ <StackPanel VerticalAlignment="Bottom" Background="{StaticResource ListViewItemOverlayBackgroundThemeBrush}">
+ <TextBlock Text="{Binding Title}" Foreground="{StaticResource ListViewItemOverlayForegroundThemeBrush}" Style="{StaticResource TitleTextStyle}" Height="60" Margin="15,0,15,0"/>
+ <TextBlock Text="{Binding Year}" Foreground="{StaticResource ListViewItemOverlaySecondaryForegroundThemeBrush}" Style="{StaticResource CaptionTextStyle}" TextWrapping="NoWrap" Margin="15,0,15,10"/>
+ </StackPanel>
+ </Grid>
+ </DataTemplate>
+
+ <DataTemplate x:Key="MovieCategoryTemplate">
+ <Grid HorizontalAlignment="Left" Width="250" Height="250">
+ <StackPanel VerticalAlignment="Bottom" Background="{StaticResource ListViewItemOverlayBackgroundThemeBrush}">
+ <TextBlock Text="{Binding}" Foreground="{StaticResource ListViewItemOverlayForegroundThemeBrush}" Style="{StaticResource TitleTextStyle}" Height="60" Margin="15,0,15,0"/>
+ </StackPanel>
+ </Grid>
+ </DataTemplate>
+
+ <x:String x:Key="AppName">WinRT GridView Performance Problems</x:String>
+ </ResourceDictionary>
+ </Application.Resources>
+</Application>
@@ -0,0 +1,103 @@
+using WinRT_GridView_XAML_Performance_Problems.Common;
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using Windows.ApplicationModel;
+using Windows.ApplicationModel.Activation;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Navigation;
+
+// The Grid App template is documented at http://go.microsoft.com/fwlink/?LinkId=234226
+
+namespace WinRT_GridView_XAML_Performance_Problems
+{
+ /// <summary>
+ /// Provides application-specific behavior to supplement the default Application class.
+ /// </summary>
+ sealed partial class App : Application
+ {
+ /// <summary>
+ /// Initializes the singleton Application object. This is the first line of authored code
+ /// executed, and as such is the logical equivalent of main() or WinMain().
+ /// </summary>
+ public App()
+ {
+ this.InitializeComponent();
+ this.Suspending += OnSuspending;
+ }
+
+ /// <summary>
+ /// Invoked when the application is launched normally by the end user. Other entry points
+ /// will be used when the application is launched to open a specific file, to display
+ /// search results, and so forth.
+ /// </summary>
+ /// <param name="args">Details about the launch request and process.</param>
+ protected override async void OnLaunched(LaunchActivatedEventArgs args)
+ {
+ Frame rootFrame = Window.Current.Content as Frame;
+
+ // Do not repeat app initialization when the Window already has content,
+ // just ensure that the window is active
+
+ if (rootFrame == null)
+ {
+ // Create a Frame to act as the navigation context and navigate to the first page
+ rootFrame = new Frame();
+ //Associate the frame with a SuspensionManager key
+ SuspensionManager.RegisterFrame(rootFrame, "AppFrame");
+
+ if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
+ {
+ // Restore the saved session state only when appropriate
+ try
+ {
+ await SuspensionManager.RestoreAsync();
+ }
+ catch (SuspensionManagerException)
+ {
+ //Something went wrong restoring state.
+ //Assume there is no state and continue
+ }
+ }
+
+ // Place the frame in the current Window
+ Window.Current.Content = rootFrame;
+ }
+ if (rootFrame.Content == null)
+ {
+ // When the navigation stack isn't restored navigate to the first page,
+ // configuring the new page by passing required information as a navigation
+ // parameter
+ if (!rootFrame.Navigate(typeof(GoodPerformancePage), "AllGroups"))
+ {
+ throw new Exception("Failed to create initial page");
+ }
+ }
+ // Ensure the current window is active
+ Window.Current.Activate();
+ }
+
+ /// <summary>
+ /// Invoked when application execution is being suspended. Application state is saved
+ /// without knowing whether the application will be terminated or resumed with the contents
+ /// of memory still intact.
+ /// </summary>
+ /// <param name="sender">The source of the suspend request.</param>
+ /// <param name="e">Details about the suspend request.</param>
+ private async void OnSuspending(object sender, SuspendingEventArgs e)
+ {
+ var deferral = e.SuspendingOperation.GetDeferral();
+ await SuspensionManager.SaveAsync();
+ deferral.Complete();
+ }
+ }
+}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,76 @@
+<common:LayoutAwarePage
+ x:Name="pageRoot"
+ x:Class="WinRT_GridView_XAML_Performance_Problems.BadPerformancePage"
+ DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:common="using:WinRT_GridView_XAML_Performance_Problems.Common"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ NavigationCacheMode="Enabled"
+ mc:Ignorable="d">
+
+ <Page.Resources>
+ <CollectionViewSource
+ x:Name="groupedItemsViewSource"
+ Source="{Binding MoviesByYear}"
+ IsSourceGrouped="true"
+ ItemsPath="Movies"/>
+
+ </Page.Resources>
+
+ <Grid Style="{StaticResource LayoutRootStyle}">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="140"/>
+ <RowDefinition Height="*"/>
+ </Grid.RowDefinitions>
+
+ <GridView
+ x:Name="itemGridView"
+ AutomationProperties.AutomationId="ItemGridView"
+ AutomationProperties.Name="Grouped Items"
+ Grid.RowSpan="2"
+ Padding="116,137,40,46"
+ ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
+ ItemTemplate="{StaticResource MovieTemplate}"
+ SelectionMode="None"
+ IsSwipeEnabled="false"
+ IsItemClickEnabled="True"
+ ItemClick="ItemView_ItemClick">
+
+ <GridView.ItemsPanel>
+ <ItemsPanelTemplate>
+ <VirtualizingStackPanel Orientation="Horizontal"/>
+ </ItemsPanelTemplate>
+ </GridView.ItemsPanel>
+ <GridView.GroupStyle>
+ <GroupStyle>
+ <GroupStyle.HeaderTemplate>
+ <DataTemplate>
+ <Grid Margin="1,0,0,6">
+ <StackPanel Orientation="Horizontal">
+ <TextBlock Text="{Binding Name}" Margin="3,-7,10,10" Style="{StaticResource GroupHeaderTextStyle}" />
+ </StackPanel>
+ </Grid>
+ </DataTemplate>
+ </GroupStyle.HeaderTemplate>
+ <GroupStyle.Panel>
+ <ItemsPanelTemplate>
+ <VariableSizedWrapGrid Orientation="Vertical" Margin="0,0,80,0"/>
+ </ItemsPanelTemplate>
+ </GroupStyle.Panel>
+ </GroupStyle>
+ </GridView.GroupStyle>
+ </GridView>
+
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="Auto"/>
+ <ColumnDefinition Width="*"/>
+ </Grid.ColumnDefinitions>
+ <Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
+ <TextBlock x:Name="pageTitle" Text="{StaticResource AppName}" Grid.Column="1" IsHitTestVisible="false" Style="{StaticResource PageHeaderTextStyle}"/>
+ </Grid>
+
+ </Grid>
+</common:LayoutAwarePage>
@@ -0,0 +1,35 @@
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Navigation;
+
+// The Grouped Items Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234231
+
+namespace WinRT_GridView_XAML_Performance_Problems
+{
+ /// <summary>
+ /// A page that displays a grouped collection of items.
+ /// </summary>
+ public sealed partial class BadPerformancePage
+ {
+ private readonly MoviesVm viewModel = new MoviesVm();
+
+ public BadPerformancePage()
+ {
+ this.InitializeComponent();
+ }
+
+ protected override void OnNavigatedTo(NavigationEventArgs e)
+ {
+ if (e.NavigationMode == NavigationMode.Back)
+ return;
+
+ this.DataContext = viewModel;
+ this.viewModel.CreateBadPerformingData();
+ }
+
+ void ItemView_ItemClick(object sender, ItemClickEventArgs e)
+ {
+ this.Frame.Navigate(typeof(MovieDetailsPage));
+ }
+ }
+
+}
@@ -0,0 +1,55 @@
+using System;
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+using Windows.UI.Xaml.Data;
+
+namespace WinRT_GridView_XAML_Performance_Problems.Common
+{
+ /// <summary>
+ /// Implementation of <see cref="INotifyPropertyChanged"/> to simplify models.
+ /// </summary>
+ [Windows.Foundation.Metadata.WebHostHidden]
+ public abstract class BindableBase : INotifyPropertyChanged
+ {
+ /// <summary>
+ /// Multicast event for property change notifications.
+ /// </summary>
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ /// <summary>
+ /// Checks if a property already matches a desired value. Sets the property and
+ /// notifies listeners only when necessary.
+ /// </summary>
+ /// <typeparam name="T">Type of the property.</typeparam>
+ /// <param name="storage">Reference to a property with both getter and setter.</param>
+ /// <param name="value">Desired value for the property.</param>
+ /// <param name="propertyName">Name of the property used to notify listeners. This
+ /// value is optional and can be provided automatically when invoked from compilers that
+ /// support CallerMemberName.</param>
+ /// <returns>True if the value was changed, false if the existing value matched the
+ /// desired value.</returns>
+ protected bool SetProperty<T>(ref T storage, T value, [CallerMemberName] String propertyName = null)
+ {
+ if (object.Equals(storage, value)) return false;
+
+ storage = value;
+ this.OnPropertyChanged(propertyName);
+ return true;
+ }
+
+ /// <summary>
+ /// Notifies listeners that a property value has changed.
+ /// </summary>
+ /// <param name="propertyName">Name of the property used to notify listeners. This
+ /// value is optional and can be provided automatically when invoked from compilers
+ /// that support <see cref="CallerMemberNameAttribute"/>.</param>
+ protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ var eventHandler = this.PropertyChanged;
+ if (eventHandler != null)
+ {
+ eventHandler(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+}
@@ -0,0 +1,21 @@
+using System;
+using Windows.UI.Xaml.Data;
+
+namespace WinRT_GridView_XAML_Performance_Problems.Common
+{
+ /// <summary>
+ /// Value converter that translates true to false and vice versa.
+ /// </summary>
+ public sealed class BooleanNegationConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, string language)
+ {
+ return !(value is bool && (bool)value);
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, string language)
+ {
+ return !(value is bool && (bool)value);
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit 9a504bf

Please sign in to comment.