This commit is contained in:
sibille 2017-03-22 14:46:31 +01:00
Родитель 547f3b0133 3742bb7182
Коммит 1200aa3632
120 изменённых файлов: 730 добавлений и 770 удалений

Просмотреть файл

@ -10,14 +10,25 @@ Param(
[string]$vsixDisplayName, [string]$vsixDisplayName,
[Parameter(Mandatory=$True,Position=4)] [Parameter(Mandatory=$True,Position=4)]
[string]$buildNumber [string]$buildNumber,
[Parameter(Mandatory=$False,Position=3)]
[string]$publicKeyToken = "e4ef4cc7a47ae0c5" #TestKey.snk
) )
$VersionRegex = "(\d+)\.(\d+)\.(\d+)\.(\d+)" $VersionRegex = "(\d+)\.(\d+)\.(\d+)\.(\d+)"
if($buildNumber -match $VersionRegEx){ if($buildNumber -match $VersionRegEx){
$versionNumber = [int]::Parse($matches[1]).ToString() + "." + [int]::Parse($matches[2]).ToString() + "." + [int]::Parse($matches[3]).ToString() + "." + [int]::Parse($matches[4]).ToString() Write-Output "Parsed Date From Build: $dateFromBuildNumber"
$revision = [int]::Parse($matches[4]).ToString()
if($buildNumber.ToLower().StartsWith("dev")){
$revision = (65000 + [int]::Parse($matches[4])).ToString();
}
$versionNumber = [int]::Parse($matches[1]).ToString() + "." + [int]::Parse($matches[2]).ToString() + "." + [int]::Parse($matches[3]).ToString() + "." + $revision
Write-Host "Version Number" $versionNumber Write-Host "Version Number" $versionNumber
} }
@ -44,24 +55,56 @@ else{
throw "Identity is mandatory." throw "Identity is mandatory."
} }
## APPLY VERSION TO ASSEMBLY FILES ## APPLY VERSION TO ASSEMBLY FILES (AssemblyVersion and AssemblyFileVersion)
Write-Host "Applying version to AssemblyInfo Files in matching the path pattern '$codePathPattern'" Write-Host "Applying version to AssemblyInfo Files in matching the path pattern '$codePathPattern'"
$files = Get-ChildItem -include "*AssemblyInfo.cs" -Recurse | Where-Object{ $_.FullName -notmatch "\\Templates\\" } $files = Get-ChildItem -include "*AssemblyInfo.cs" -Recurse | Where-Object{ $_.FullName -notmatch "\\Templates\\" }
if($files) if($files)
{ {
Write-Host "Will apply $versionNumber to $($files.count) files." Write-Host "Will apply $versionNumber to $($files.count) files."
$assemblyFileVersionRegEx = "AssemblyFileVersion\(""(\d+)\.(\d+)\.(\d+)\.(\d+)""\)" $assemblyVersionRegEx = "\(""$VersionRegex""\)"
$assemblyFileVersionReplacement = "AssemblyFileVersion(""$versionNumber"")" $assemblyVersionReplacement = "(""$versionNumber"")"
foreach ($file in $files) { foreach ($file in $files) {
$filecontent = Get-Content($file) $filecontent = Get-Content($file)
attrib $file -r attrib $file -r
$filecontent -replace $assemblyFileVersionRegEx, $assemblyFileVersionReplacement | Out-File $file utf8 $filecontent -replace $assemblyVersionRegEx, $assemblyVersionReplacement | Out-File $file utf8
Write-Host "$file - version applied" Write-Host "$file - version applied"
} }
} }
else else
{ {
Write-Warning "No files found to apply version." Write-Warning "No files found to apply version."
}
## APPLY VERSION TO PROJECT TEMPLATE WIZARD REFERENCE
if($publicKeyToken){
Write-Host "Setting Wizard Extension configuration in Project Template"
$projectTemplate = Get-ChildItem -include "*.vstemplate" -recurse | Where-Object{
$_.FullName -notmatch "\\Templates\\" -and
$_.FullName -notmatch "\\debug\\" -and
$_.FullName -notmatch "\\obj\\" -and
$_.FullName -match "\\ProjectTemplates\\"
}
if($projectTemplate){
[xml]$projectTemplateContent = Get-Content $projectTemplate
$newPublicKeyToken = "PublicKeyToken=$publicKeyToken"
$wizardAssemblyStrongName = $projectTemplateContent.VSTemplate.WizardExtension.Assembly -replace $VersionRegEx, $versionNumber
$wizardAssemblyStrongName = $wizardAssemblyStrongName -replace "PublicKeyToken=.*</Assembly>", "$newPublicKeyToken</Assembly>"
$projectTemplateContent.VSTemplate.WizardExtension.Assembly = $wizardAssemblyStrongName
$projectTemplateContent.Save($projectTemplate)
Write-Host "$projectTemplate - Wizard Assembly Strong Name updated ($wizardAssemblyStrongName)"
}
else{
throw "No Project Template manifest file found!"
}
}
else{
throw "Public key token not set."
} }

Просмотреть файл

@ -44,15 +44,31 @@ namespace Microsoft.Templates.Core
string result = String.Empty; string result = String.Empty;
foreach(var mp in Instance?.Settings.SettingsLoader.MountPoints) foreach(var mp in Instance?.Settings.SettingsLoader.MountPoints)
{ {
if (Directory.Exists(mp.Place)) if (Directory.Exists(mp.Place) && IsHigherVersion(result, mp.Place))
{ {
//TODO RAGC: ENSURE EXITSI AND THE VERSION IS HIGHER!!!!
result = mp.Place; result = mp.Place;
} }
} }
return result; return result;
} }
private bool IsHigherVersion(string currentPlace, string newPlace)
{
Version.TryParse(currentPlace, out Version current);
Version.TryParse(Path.GetFileName(newPlace), out Version newp);
if(newp == null)
{
return false;
}
if (newp != null && current == null)
{
return true;
}
return newp > current;
}
private void Init() private void Init()
{ {

Просмотреть файл

@ -9,7 +9,7 @@ namespace Microsoft.Templates.Core
{ {
public class Naming public class Naming
{ {
private static readonly string[] ReservedNames = new string[] { "WebView", "Page", "BackgroundTask", "PivotPage" }; private static readonly string[] ReservedNames = new string[] { "WebView", "Page", "BackgroundTask", "Pivot" };
private const string ValidationPattern = @"^([a-zA-Z])([\w\-])*$"; private const string ValidationPattern = @"^([a-zA-Z])([\w\-])*$";
private const string InferInvalidPattern = @"[^a-zA-Z\d_\-]"; private const string InferInvalidPattern = @"[^a-zA-Z\d_\-]";
@ -54,6 +54,15 @@ namespace Microsoft.Templates.Core
ErrorType = ValidationErrorType.AlreadyExists ErrorType = ValidationErrorType.AlreadyExists
}; };
} }
if (ReservedNames.Contains(value))
{
return new ValidationResult
{
IsValid = false,
ErrorType = ValidationErrorType.ReservedName
};
}
var m = Regex.Match(value, ValidationPattern); var m = Regex.Match(value, ValidationPattern);
if (!m.Success) if (!m.Success)
{ {
@ -88,6 +97,7 @@ namespace Microsoft.Templates.Core
None, None,
Empty, Empty,
AlreadyExists, AlreadyExists,
BadFormat BadFormat,
ReservedName
} }
} }

Просмотреть файл

@ -68,9 +68,9 @@ namespace Microsoft.Templates.Wizard
{ {
var genItems = GenComposer.Compose(userSelection).ToList(); var genItems = GenComposer.Compose(userSelection).ToList();
Stopwatch chrono = Stopwatch.StartNew(); var chrono = Stopwatch.StartNew();
Dictionary<string, TemplateCreationResult> genResults = new Dictionary<string, TemplateCreationResult>(); var genResults = new Dictionary<string, TemplateCreationResult>();
foreach (var genInfo in genItems) foreach (var genInfo in genItems)
{ {
@ -155,12 +155,23 @@ namespace Microsoft.Templates.Wizard
private static void ShowError(Exception ex, WizardState userSelection = null) private static void ShowError(Exception ex, WizardState userSelection = null)
{ {
AppHealth.Current.Error.TrackAsync(ex.ToString()).FireAndForget(); AppHealth.Current.Error.TrackAsync(ex.ToString()).FireAndForget();
AppHealth.Current.Exception.TrackAsync(ex, userSelection?.ToString()).FireAndForget(); AppHealth.Current.Exception.TrackAsync(ex, GetExceptionTrackMessage(userSelection)).FireAndForget();
var error = new ErrorDialog(ex); var error = new ErrorDialog(ex);
GenContext.ToolBox.Shell.ShowModal(error); GenContext.ToolBox.Shell.ShowModal(error);
} }
private static string GetExceptionTrackMessage(WizardState userSelection = null)
{
var sb = new StringBuilder();
sb.AppendLine($"Templates v: '{GenContext.ToolBox.Repo.GetVersion()}'");
if (userSelection != null)
{
sb.AppendLine(userSelection.ToString());
}
return sb.ToString();
}
private static void CleanStatusBar() private static void CleanStatusBar()
{ {
GenContext.ToolBox.Shell.ShowStatusBarMessage(string.Empty); GenContext.ToolBox.Shell.ShowStatusBarMessage(string.Empty);
@ -190,7 +201,7 @@ namespace Microsoft.Templates.Wizard
} }
} }
} }
catch (System.Exception ex) catch (Exception ex)
{ {
AppHealth.Current.Exception.TrackAsync(ex, "Exception tracking telemetry for Template Generation.").FireAndForget(); AppHealth.Current.Exception.TrackAsync(ex, "Exception tracking telemetry for Template Generation.").FireAndForget();
} }

Просмотреть файл

@ -58,9 +58,7 @@ namespace Microsoft.Templates.Wizard.Steps.ConsumerFeatures.NewConsumerFeature
{ {
SetProperty(ref _itemName, value); SetProperty(ref _itemName, value);
var validationResult = Naming.Validate(_selectedNames, value); Validate(value);
HandleValidation(validationResult);
OnPropertyChanged(nameof(OkCommand)); OnPropertyChanged(nameof(OkCommand));
} }
@ -126,6 +124,13 @@ namespace Microsoft.Templates.Wizard.Steps.ConsumerFeatures.NewConsumerFeature
} }
} }
private void Validate(string value)
{
var validationResult = Naming.Validate(_selectedNames, value);
HandleValidation(validationResult);
}
private bool IsValid() => _isValid; private bool IsValid() => _isValid;
} }
} }

Просмотреть файл

@ -158,5 +158,23 @@ namespace Microsoft.Templates.Wizard.Steps.ConsumerFeatures {
return ResourceManager.GetString("ValidationError_Empty", resourceCulture); return ResourceManager.GetString("ValidationError_Empty", resourceCulture);
} }
} }
/// <summary>
/// Looks up a localized string similar to Cannot set a custom name.
/// </summary>
public static string ValidationError_RenameNotAllowed {
get {
return ResourceManager.GetString("ValidationError_RenameNotAllowed", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Name is reserved.
/// </summary>
public static string ValidationError_ReservedName {
get {
return ResourceManager.GetString("ValidationError_ReservedName", resourceCulture);
}
}
} }
} }

Просмотреть файл

@ -150,4 +150,10 @@
<data name="ValidationError_Empty" xml:space="preserve"> <data name="ValidationError_Empty" xml:space="preserve">
<value>Name cannot be empty</value> <value>Name cannot be empty</value>
</data> </data>
<data name="ValidationError_RenameNotAllowed" xml:space="preserve">
<value>Cannot set a custom name</value>
</data>
<data name="ValidationError_ReservedName" xml:space="preserve">
<value>Name is reserved</value>
</data>
</root> </root>

Просмотреть файл

@ -58,9 +58,7 @@ namespace Microsoft.Templates.Wizard.Steps.DevFeatures.NewDevFeature
{ {
SetProperty(ref _itemName, value); SetProperty(ref _itemName, value);
var validationResult = Naming.Validate(_selectedNames, value); Validate(value);
HandleValidation(validationResult);
OnPropertyChanged(nameof(OkCommand)); OnPropertyChanged(nameof(OkCommand));
} }
@ -125,6 +123,13 @@ namespace Microsoft.Templates.Wizard.Steps.DevFeatures.NewDevFeature
} }
} }
private void Validate(string value)
{
var validationResult = Naming.Validate(_selectedNames, value);
HandleValidation(validationResult);
}
private bool IsValid() => _isValid; private bool IsValid() => _isValid;
} }
} }

18
code/src/Wizard/Steps/DevFeatures/Strings.Designer.cs сгенерированный
Просмотреть файл

@ -158,5 +158,23 @@ namespace Microsoft.Templates.Wizard.Steps.DevFeatures {
return ResourceManager.GetString("ValidationError_Empty", resourceCulture); return ResourceManager.GetString("ValidationError_Empty", resourceCulture);
} }
} }
/// <summary>
/// Looks up a localized string similar to Cannot set a custom name.
/// </summary>
public static string ValidationError_RenameNotAllowed {
get {
return ResourceManager.GetString("ValidationError_RenameNotAllowed", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Name is reserved.
/// </summary>
public static string ValidationError_ReservedName {
get {
return ResourceManager.GetString("ValidationError_ReservedName", resourceCulture);
}
}
} }
} }

Просмотреть файл

@ -150,4 +150,10 @@
<data name="ValidationError_Empty" xml:space="preserve"> <data name="ValidationError_Empty" xml:space="preserve">
<value>Name cannot be empty</value> <value>Name cannot be empty</value>
</data> </data>
<data name="ValidationError_RenameNotAllowed" xml:space="preserve">
<value>Cannot set a custom name</value>
</data>
<data name="ValidationError_ReservedName" xml:space="preserve">
<value>Name is reserved</value>
</data>
</root> </root>

Просмотреть файл

@ -56,15 +56,13 @@ namespace Microsoft.Templates.Wizard.Steps.Pages.NewPage
{ {
SetProperty(ref _itemName, value); SetProperty(ref _itemName, value);
var validationResult = Naming.Validate(_selectedNames, value); Validate(value);
HandleValidation(validationResult);
OnPropertyChanged(nameof(OkCommand)); OnPropertyChanged(nameof(OkCommand));
} }
} }
//TODO: MAKE THIS METHOD TRULY ASYNC //TODO: MAKE THIS METHOD TRULY ASYNC
public async Task InitializeAsync() public async Task InitializeAsync()
{ {
Templates.Clear(); Templates.Clear();
@ -114,6 +112,13 @@ namespace Microsoft.Templates.Wizard.Steps.Pages.NewPage
} }
} }
private void Validate(string value)
{
var validationResult = Naming.Validate(_selectedNames, value);
HandleValidation(validationResult);
}
private bool IsValid() => _isValid; private bool IsValid() => _isValid;
} }
} }

18
code/src/Wizard/Steps/Pages/Strings.Designer.cs сгенерированный
Просмотреть файл

@ -149,5 +149,23 @@ namespace Microsoft.Templates.Wizard.Steps.Pages {
return ResourceManager.GetString("ValidationError_Empty", resourceCulture); return ResourceManager.GetString("ValidationError_Empty", resourceCulture);
} }
} }
/// <summary>
/// Looks up a localized string similar to Cannot set a custom name.
/// </summary>
public static string ValidationError_RenameNotAllowed {
get {
return ResourceManager.GetString("ValidationError_RenameNotAllowed", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Name is reserved.
/// </summary>
public static string ValidationError_ReservedName {
get {
return ResourceManager.GetString("ValidationError_ReservedName", resourceCulture);
}
}
} }
} }

Просмотреть файл

@ -147,4 +147,10 @@
<data name="ValidationError_Empty" xml:space="preserve"> <data name="ValidationError_Empty" xml:space="preserve">
<value>Name cannot be empty</value> <value>Name cannot be empty</value>
</data> </data>
<data name="ValidationError_RenameNotAllowed" xml:space="preserve">
<value>Cannot set a custom name</value>
</data>
<data name="ValidationError_ReservedName" xml:space="preserve">
<value>Name is reserved</value>
</data>
</root> </root>

Просмотреть файл

@ -1,7 +1,7 @@
|Env|CI |Templates Publishing |Extension Publishing | |Env|CI |Templates Publishing |Extension Publishing |
|:-----|:--------:|:-------------------:|:-------------------:| |:-----|:--------:|:-------------------:|:-------------------:|
|dev|![CI Build](https://winappstudio.visualstudio.com/_apis/public/build/definitions/5c80cfe7-3bfb-4799-9d04-803c84df7a60/121/badge) | ![Templates Publishing Build](https://winappstudio.visualstudio.com/_apis/public/build/definitions/5c80cfe7-3bfb-4799-9d04-803c84df7a60/123/badge) | ![Extension Publishing Build](https://winappstudio.visualstudio.com/_apis/public/build/definitions/5c80cfe7-3bfb-4799-9d04-803c84df7a60/122/badge)| |dev|![CI Build](https://winappstudio.visualstudio.com/_apis/public/build/definitions/5c80cfe7-3bfb-4799-9d04-803c84df7a60/121/badge) | ![Templates Publishing Build](https://winappstudio.visualstudio.com/_apis/public/build/definitions/5c80cfe7-3bfb-4799-9d04-803c84df7a60/123/badge) | ![Extension Publishing Build](https://winappstudio.visualstudio.com/_apis/public/build/definitions/5c80cfe7-3bfb-4799-9d04-803c84df7a60/122/badge)|
|pre-release|[CI Build](https://winappstudio.visualstudio.com/_apis/public/build/definitions/5c80cfe7-3bfb-4799-9d04-803c84df7a60/125/badge)|[Templates Publishing Build](https://winappstudio.visualstudio.com/_apis/public/build/definitions/5c80cfe7-3bfb-4799-9d04-803c84df7a60/124/badge)|[Extension Publishing Build](https://winappstudio.visualstudio.com/_apis/public/build/definitions/5c80cfe7-3bfb-4799-9d04-803c84df7a60/126/badge)| |pre-release|![CI Build](https://winappstudio.visualstudio.com/_apis/public/build/definitions/5c80cfe7-3bfb-4799-9d04-803c84df7a60/125/badge)|![Templates Publishing Build](https://winappstudio.visualstudio.com/_apis/public/build/definitions/5c80cfe7-3bfb-4799-9d04-803c84df7a60/124/badge)|![Extension Publishing Build](https://winappstudio.visualstudio.com/_apis/public/build/definitions/5c80cfe7-3bfb-4799-9d04-803c84df7a60/126/badge)|
UWP Community Template Generator UWP Community Template Generator
=========== ===========

Просмотреть файл

@ -0,0 +1,14 @@
using ItemNamespace.ViewModel;
namespace ItemNamespace.View
{
public sealed partial class uct.ItemNamePage : Page
{
public uct.ItemNameViewModel ViewModel { get; } = new uct.ItemNameViewModel();
public uct.ItemNamePage()
{
DataContext = ViewModel;
this.InitializeComponent();
}
}
}

Просмотреть файл

@ -1,10 +0,0 @@
public sealed partial class uct.ItemNamePage : Page
{
public uct.ItemNameViewModel ViewModel { get; } = new uct.ItemNameViewModel();
public uct.ItemNamePage()
{
DataContext = ViewModel;
this.InitializeComponent();
}
}

Просмотреть файл

@ -1,5 +1,6 @@
using ItemNamespace.uct.ItemName; using ItemNamespace.Model;
namespace ItemNamespace.Shell using ItemNamespace.View;
namespace ItemNamespace.ViewModel
{ {
public class ShellViewModel : Observable public class ShellViewModel : Observable
{ {

Просмотреть файл

@ -20,10 +20,10 @@
"preferNameDirectory": true, "preferNameDirectory": true,
"PrimaryOutputs": [ "PrimaryOutputs": [
{ {
"path": ".\\Shell\\ShellNavigationItem.cs" "path": ".\\Model\\ShellNavigationItem.cs"
}, },
{ {
"path": ".\\Shell\\ShellViewModel.cs" "path": ".\\ViewModel\\ShellViewModel.cs"
} }
], ],
"symbols": { "symbols": {

Просмотреть файл

@ -2,7 +2,7 @@
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
namespace uct.ItemName.Shell namespace uct.ItemName.Model
{ {
public class ShellNavigationItem public class ShellNavigationItem
{ {

Просмотреть файл

@ -1,12 +0,0 @@
public sealed partial class ShellPage : Page
{
public ShellViewModel ViewModel { get; } = new ShellViewModel();
public ShellPage()
{
DataContext = ViewModel;
this.InitializeComponent();
NavigationService.SetNavigationFrame(frame);
}
}

Просмотреть файл

@ -0,0 +1,16 @@
using RootNamespace.ViewModel;
namespace RootNamespace.View
{
public sealed partial class ShellView : Page
{
public ShellViewModel ViewModel { get; } = new ShellViewModel();
public ShellView()
{
DataContext = ViewModel;
this.InitializeComponent();
NavigationService.SetNavigationFrame(frame);
}
}
}

Просмотреть файл

@ -4,10 +4,11 @@ using System.Linq;
using System.Windows.Input; using System.Windows.Input;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation; using Windows.UI.Xaml.Navigation;
using uct.ItemName.Model;
using uct.ItemName.Mvvm; using uct.ItemName.Mvvm;
using uct.ItemName.Services; using uct.ItemName.Services;
namespace uct.ItemName.Shell namespace uct.ItemName.ViewModel
{ {
public class ShellViewModel : Observable public class ShellViewModel : Observable
{ {

Просмотреть файл

@ -1,11 +0,0 @@
namespace ItemNamespace.PivotPage
{
public class PivotPageViewModel : Observable
{
public PivotPageViewModel()
{
//^^
Items.Add(new PivotTabbedItem("PivotPage_uct.ItemName".GetLocalized(), new uct.ItemName.uct.ItemNamePage()));
}
}
}

Просмотреть файл

@ -1,7 +1,7 @@
<root> <root>
<!--^^--> <!--^^-->
<!--{[{--> <!--{[{-->
<data name="PivotPage_uct.ItemName" xml:space="preserve"> <data name="PivotView_uct.ItemName" xml:space="preserve">
<value>uct.ItemName</value> <value>uct.ItemName</value>
</data> </data>
<!--}]}--> <!--}]}-->

Просмотреть файл

@ -0,0 +1,12 @@
using ItemNamespace.View;
namespace ItemNamespace.ViewModel
{
public class PivotViewModel : Observable
{
public PivotViewModel()
{
//^^
Items.Add(new PivotTabbedItem("PivotView_uct.ItemName".GetLocalized(), new uct.ItemNamePage()));
}
}
}

Просмотреть файл

@ -20,7 +20,7 @@
"preferNameDirectory": true, "preferNameDirectory": true,
"PrimaryOutputs": [ "PrimaryOutputs": [
{ {
"path": ".\\PivotPage\\PivotPageViewModel.cs" "path": ".\\ViewModel\\PivotViewModel.cs"
} }
], ],
"symbols": { "symbols": {

Просмотреть файл

@ -1,10 +0,0 @@
public sealed partial class PivotPage : Page
{
public PivotPageViewModel ViewModel { get; } = new PivotPageViewModel();
public PivotPage()
{
DataContext = ViewModel;
this.InitializeComponent();
}
}

Просмотреть файл

@ -0,0 +1,10 @@
public sealed partial class PivotView : Page
{
public PivotViewModel ViewModel { get; } = new PivotViewModel();
public PivotView()
{
DataContext = ViewModel;
this.InitializeComponent();
}
}

Просмотреть файл

@ -1,10 +1,11 @@
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Windows.Input; using System.Windows.Input;
using uct.ItemName.Model;
using uct.ItemName.Mvvm; using uct.ItemName.Mvvm;
namespace uct.ItemName.PivotPage namespace uct.ItemName.ViewModel
{ {
public class PivotPageViewModel : Observable public class PivotViewModel : Observable
{ {
private ObservableCollection<PivotTabbedItem> _items = new ObservableCollection<PivotTabbedItem>(); private ObservableCollection<PivotTabbedItem> _items = new ObservableCollection<PivotTabbedItem>();
public ObservableCollection<PivotTabbedItem> Items public ObservableCollection<PivotTabbedItem> Items
@ -13,7 +14,7 @@ namespace uct.ItemName.PivotPage
set { Set(ref _items, value); } set { Set(ref _items, value); }
} }
public PivotPageViewModel() public PivotViewModel()
{ {
//TODO: UWPTemplates -> Show pages in Pivot by adding a navigation item for each page with its name. //TODO: UWPTemplates -> Show pages in Pivot by adding a navigation item for each page with its name.
//Edit String/en-US/Resources.resw: Add a menu item title for each page //Edit String/en-US/Resources.resw: Add a menu item title for each page

Просмотреть файл

@ -21,9 +21,6 @@
"sourceName": "uct.ItemName", "sourceName": "uct.ItemName",
"preferNameDirectory": true, "preferNameDirectory": true,
"PrimaryOutputs": [ "PrimaryOutputs": [
{
"path": ".\\uct.ItemName\\ViewModelLocator.cs"
}
], ],
"symbols": { "symbols": {
"rootNamespace": { "rootNamespace": {

Просмотреть файл

@ -0,0 +1,14 @@
using ItemNamespace.ViewModel;
namespace ItemNamespace.View
{
public sealed partial class uct.ItemNamePage : Page
{
//{[{
private uct.ItemNameViewModel ViewModel
{
get { return DataContext as uct.ItemNameViewModel; }
}
//}]}
}
}

Просмотреть файл

@ -1,6 +1,6 @@
using GalaSoft.MvvmLight; using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
namespace ItemNamespace.uct.ItemName namespace ItemNamespace.ViewModel
{ {
} }

Просмотреть файл

@ -1,5 +1,17 @@
public ViewModelLocator() public class ViewModelLocator
{ {
//^^ public ViewModelLocator()
Registeruct.ItemName(navigationService); {
//^^
Registeruct.ItemName(navigationService);
}
public uct.ItemNameViewModel uct.ItemNameViewModel => ServiceLocator.Current.GetInstance<uct.ItemNameViewModel>();
//{[{
public void Registeruct.ItemName(NavigationService navigationService)
{
SimpleIoc.Default.Register<uct.ItemNameViewModel>();
navigationService.Configure(typeof(uct.ItemNameViewModel).FullName, typeof(uct.ItemNamePage));
}
//}]}
} }

Просмотреть файл

@ -1,18 +0,0 @@
using Microsoft.Practices.ServiceLocation;
using GalaSoft.MvvmLight.Ioc;
using RootNamespace.Services;
using RootNamespace.uct.ItemName;
namespace RootNamespace
{
public partial class ViewModelLocator
{
public uct.ItemNameViewModel uct.ItemNameViewModel => ServiceLocator.Current.GetInstance<uct.ItemNameViewModel>();
public void Registeruct.ItemName(NavigationService navigationService)
{
SimpleIoc.Default.Register<uct.ItemNameViewModel>();
navigationService.Configure(typeof(uct.ItemNameViewModel).FullName, typeof(uct.ItemNamePage));
}
}
}

Просмотреть файл

@ -1,4 +0,0 @@
public sealed partial class uct.ItemNamePage : Page
{
private uct.ItemNameViewModel ViewModel { get { return DataContext as uct.ItemNameViewModel; } }
}

Просмотреть файл

@ -1,5 +1,4 @@
using ItemNamespace.uct.ItemName; namespace ItemNamespace.ViewModel
namespace ItemNamespace.Shell
{ {
public class ShellViewModel : ViewModelBase public class ShellViewModel : ViewModelBase
{ {

Просмотреть файл

@ -20,13 +20,10 @@
"preferNameDirectory": true, "preferNameDirectory": true,
"PrimaryOutputs": [ "PrimaryOutputs": [
{ {
"path": ".\\Shell\\ShellNavigationItem.cs" "path": ".\\Model\\ShellNavigationItem.cs"
}, },
{ {
"path": ".\\Shell\\ShellViewModel.cs" "path": ".\\ViewModel\\ShellViewModel.cs"
},
{
"path": ".\\Shell\\ViewModelLocator.cs"
} }
], ],
"symbols": { "symbols": {

Просмотреть файл

@ -2,7 +2,7 @@
using Windows.ApplicationModel.Resources; using Windows.ApplicationModel.Resources;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
namespace uct.ItemName.Shell namespace uct.ItemName.Model
{ {
public class ShellNavigationItem public class ShellNavigationItem
{ {

Просмотреть файл

@ -1,14 +0,0 @@
using Microsoft.Practices.ServiceLocation;
using GalaSoft.MvvmLight.Ioc;
using RootNamespace.Shell;
namespace RootNamespace
{
public partial class ViewModelLocator
{
public ShellViewModel ShellViewModel => ServiceLocator.Current.GetInstance<ShellViewModel>();
public void RegisterShell() => SimpleIoc.Default.Register<ShellViewModel>();
}
}

Просмотреть файл

@ -1,13 +1,14 @@
using Microsoft.Practices.ServiceLocation; using ItemNamespace.ViewModel;
namespace uct.ItemName.Shell using Microsoft.Practices.ServiceLocation;
namespace uct.ItemName.View
{ {
public sealed partial class ShellPage : Page public sealed partial class ShellView : Page
{ {
private ShellViewModel ViewModel { get { return DataContext as ShellViewModel; } } private ShellViewModel ViewModel { get { return DataContext as ShellViewModel; } }
private NavigationService navigationService { get { return ServiceLocator.Current.GetInstance<NavigationService>(); } } private NavigationService navigationService { get { return ServiceLocator.Current.GetInstance<NavigationService>(); } }
public ShellPage() public ShellView()
{ {
this.InitializeComponent(); this.InitializeComponent();

Просмотреть файл

@ -8,8 +8,9 @@ using Windows.UI.Xaml.Navigation;
using GalaSoft.MvvmLight; using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
using uct.ItemName.Services; using uct.ItemName.Services;
using uct.ItemName.Model;
namespace uct.ItemName.Shell namespace uct.ItemName.ViewModel
{ {
public class ShellViewModel : ViewModelBase public class ShellViewModel : ViewModelBase
{ {

Просмотреть файл

@ -1,5 +1,11 @@
public ViewModelLocator() public class ViewModelLocator
{ {
//^^ public ViewModelLocator()
RegisterShell(); {
} //^^
RegisterShell();
}
public ShellViewModel ShellViewModel => ServiceLocator.Current.GetInstance<ShellViewModel>();
public void RegisterShell() => SimpleIoc.Default.Register<ShellViewModel>();
}

Просмотреть файл

@ -1,11 +0,0 @@
namespace ItemNamespace.PivotPage
{
public class PivotPageViewModel : ViewModelBase
{
public PivotPageViewModel()
{
//^^
Items.Add(new PivotTabbedItem("PivotPage_uct.ItemName".GetLocalized(), new uct.ItemName.uct.ItemNamePage()));
}
}
}

Просмотреть файл

@ -1,7 +1,7 @@
<root> <root>
<!--^^--> <!--^^-->
<!--{[{--> <!--{[{-->
<data name="PivotPage_uct.ItemName" xml:space="preserve"> <data name="PivotView_uct.ItemName" xml:space="preserve">
<value>uct.ItemName</value> <value>uct.ItemName</value>
</data> </data>
<!--}]}--> <!--}]}-->

Просмотреть файл

@ -0,0 +1,13 @@
using ItemNamespace.Model;
using ItemNamespace.View;
namespace ItemNamespace.ViewModel
{
public class PivotViewModel : ViewModelBase
{
public PivotViewModel()
{
//^^
Items.Add(new PivotTabbedItem("PivotView_uct.ItemName".GetLocalized(), new uct.ItemNamePage()));
}
}
}

Просмотреть файл

@ -20,10 +20,7 @@
"preferNameDirectory": true, "preferNameDirectory": true,
"PrimaryOutputs": [ "PrimaryOutputs": [
{ {
"path": ".\\PivotPage\\PivotPageViewModel.cs" "path": ".\\ViewModel\\PivotViewModel.cs"
},
{
"path": ".\\PivotPage\\ViewModelLocator.cs"
} }
], ],
"symbols": { "symbols": {

Просмотреть файл

@ -1,4 +0,0 @@
public sealed partial class PivotPage : Page
{
private PivotPageViewModel ViewModel { get { return DataContext as PivotPageViewModel; } }
}

Просмотреть файл

@ -1,18 +0,0 @@
using GalaSoft.MvvmLight.Ioc;
using Microsoft.Practices.ServiceLocation;
using uct.ItemName.PivotPage;
using uct.ItemName.Services;
namespace uct.ItemName
{
public partial class ViewModelLocator
{
public PivotPageViewModel PivotPageViewModel => ServiceLocator.Current.GetInstance<PivotPageViewModel>();
public void RegisterPivotPage(NavigationService navigationService)
{
SimpleIoc.Default.Register<PivotPageViewModel>();
navigationService.Configure(typeof(PivotPageViewModel).FullName, typeof(PivotPage.PivotPage));
}
}
}

Просмотреть файл

@ -1,5 +1,5 @@
<Page <Page
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
DataContext="{Binding PivotPageViewModel, Source={StaticResource Locator}}" DataContext="{Binding PivotViewModel, Source={StaticResource Locator}}"
mc:Ignorable="d"> mc:Ignorable="d">
</Page> </Page>

Просмотреть файл

@ -0,0 +1,7 @@
namespace RootNamespace.View
{
public sealed partial class PivotView : Page
{
private PivotViewModel ViewModel { get { return DataContext as PivotViewModel; } }
}
}

Просмотреть файл

@ -1,9 +1,10 @@
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using GalaSoft.MvvmLight; using GalaSoft.MvvmLight;
using uct.ItemName.Model;
namespace uct.ItemName.PivotPage namespace uct.ItemName.ViewModel
{ {
public class PivotPageViewModel : ViewModelBase public class PivotViewModel : ViewModelBase
{ {
private ObservableCollection<PivotTabbedItem> _items = new ObservableCollection<PivotTabbedItem>(); private ObservableCollection<PivotTabbedItem> _items = new ObservableCollection<PivotTabbedItem>();
public ObservableCollection<PivotTabbedItem> Items public ObservableCollection<PivotTabbedItem> Items
@ -12,7 +13,7 @@ namespace uct.ItemName.PivotPage
set { Set(ref _items, value); } set { Set(ref _items, value); }
} }
public PivotPageViewModel() public PivotViewModel()
{ {
//TODO: UWPTemplates -> Show pages in Pivot by adding a navigation item for each page with its name. //TODO: UWPTemplates -> Show pages in Pivot by adding a navigation item for each page with its name.
//Edit String/en-US/Resources.resw: Add a menu item title for each page //Edit String/en-US/Resources.resw: Add a menu item title for each page

Просмотреть файл

@ -1,5 +1,17 @@
public ViewModelLocator() public class ViewModelLocator
{ {
//^^ public ViewModelLocator()
RegisterPivotPage(navigationService); {
//^^
RegisterPivotView(navigationService);
}
public PivotViewModel PivotViewModel => ServiceLocator.Current.GetInstance<PivotViewModel>();
//{[{
public void RegisterPivotView(NavigationService navigationService)
{
SimpleIoc.Default.Register<PivotViewModel>();
navigationService.Configure(typeof(PivotViewModel).FullName, typeof(PivotView));
}
//}]}
} }

Просмотреть файл

@ -1,15 +1,18 @@
using GalaSoft.MvvmLight.Ioc; using GalaSoft.MvvmLight.Ioc;
using Microsoft.Practices.ServiceLocation; using Microsoft.Practices.ServiceLocation;
using RootNamespace.Services;
using RootNamespace.View;
using RootNamespace.ViewModel;
namespace RootNamespace namespace RootNamespace
{ {
public partial class ViewModelLocator public class ViewModelLocator
{ {
public ViewModelLocator() public ViewModelLocator()
{ {
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
var navigationService = new Services.NavigationService(); var navigationService = new NavigationService();
SimpleIoc.Default.Register(() => navigationService); SimpleIoc.Default.Register(() => navigationService);
} }

Просмотреть файл

@ -20,13 +20,13 @@
"preferNameDirectory": true, "preferNameDirectory": true,
"PrimaryOutputs": [ "PrimaryOutputs": [
{ {
"path": ".\\BlankPage\\BlankPagePage.xaml" "path": ".\\View\\BlankPagePage.xaml"
}, },
{ {
"path": ".\\BlankPage\\BlankPagePage.xaml.cs" "path": ".\\View\\BlankPagePage.xaml.cs"
}, },
{ {
"path": ".\\BlankPage\\BlankPageViewModel.cs" "path": ".\\ViewModel\\BlankPageViewModel.cs"
} }
], ],
"symbols": { "symbols": {

Просмотреть файл

@ -1,5 +1,5 @@
<Page <Page
x:Class="ItemNamespace.BlankPage.BlankPagePage" x:Class="ItemNamespace.View.BlankPagePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

Просмотреть файл

@ -1,6 +1,6 @@
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
namespace ItemNamespace.BlankPage namespace ItemNamespace.View
{ {
public sealed partial class BlankPagePage : Page public sealed partial class BlankPagePage : Page
{ {

Просмотреть файл

@ -1,6 +1,5 @@
using System; using System;
namespace ItemNamespace.ViewModel
namespace ItemNamespace.BlankPage
{ {
public class BlankPageViewModel : System.ComponentModel.INotifyPropertyChanged public class BlankPageViewModel : System.ComponentModel.INotifyPropertyChanged
{ {

Просмотреть файл

@ -19,9 +19,9 @@
"preferNameDirectory": true, "preferNameDirectory": true,
"PrimaryOutputs": "PrimaryOutputs":
[ [
{ "path": ".\\MapPage\\MapPagePage.xaml" }, { "path": ".\\View\\MapPagePage.xaml" },
{ "path": ".\\MapPage\\MapPagePage.xaml.cs" }, { "path": ".\\View\\MapPagePage.xaml.cs" },
{ "path": ".\\MapPage\\MapPageViewModel.cs" }, { "path": ".\\ViewModel\\MapPageViewModel.cs" },
{ "path": ".\\Assets\\map.png" } { "path": ".\\Assets\\map.png" }
], ],
"symbols": { "symbols": {

Просмотреть файл

@ -1,10 +1,11 @@
<Page <Page
x:Class="ItemNamespace.MapPage.MapPagePage" x:Class="ItemNamespace.View.MapPagePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:maps="using:Windows.UI.Xaml.Controls.Maps" xmlns:maps="using:Windows.UI.Xaml.Controls.Maps"
Loaded="OnLoaded"
mc:Ignorable="d"> mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

Просмотреть файл

@ -1,8 +1,8 @@
using System; using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
namespace ItemNamespace.MapPage namespace ItemNamespace.View
{ {
public sealed partial class MapPagePage : Page public sealed partial class MapPagePage : Page
{ {
@ -11,7 +11,7 @@ namespace ItemNamespace.MapPage
this.InitializeComponent(); this.InitializeComponent();
} }
protected override void OnNavigatedTo(NavigationEventArgs e) private void OnLoaded(object sender, RoutedEventArgs e)
{ {
if (ViewModel == null) if (ViewModel == null)
{ {

Просмотреть файл

@ -5,7 +5,7 @@ using Windows.Foundation;
using Windows.Storage.Streams; using Windows.Storage.Streams;
using Windows.UI.Xaml.Controls.Maps; using Windows.UI.Xaml.Controls.Maps;
namespace ItemNamespace.MapPage namespace ItemNamespace.ViewModel
{ {
public class MapPageViewModel : System.ComponentModel.INotifyPropertyChanged public class MapPageViewModel : System.ComponentModel.INotifyPropertyChanged
{ {

Просмотреть файл

@ -20,56 +20,20 @@
"preferNameDirectory": true, "preferNameDirectory": true,
"PrimaryOutputs": [ "PrimaryOutputs": [
{ {
"path": ".\\MasterDetailPage\\MasterDetailPagePage.xaml" "path": ".\\View\\MasterDetailPagePage.xaml"
}, },
{ {
"path": ".\\MasterDetailPage\\MasterDetailPagePage.xaml.cs" "path": ".\\View\\MasterDetailPagePage.xaml.cs"
}, },
{ {
"path": ".\\MasterDetailPage\\MasterDetailPageViewModel.cs" "path": ".\\ViewModel\\MasterDetailPageViewModel.cs"
}, },
{ {
"path": ".\\MasterDetailPage\\DessertModel.cs" "path": ".\\Model\\SampleModel.cs"
}, },
{ {
"path": ".\\MasterDetailPage\\DessertService.cs" "path": ".\\Services\\SampleModelService.cs"
}, }
{
"path": ".\\MasterDetailPage\\Images\\60Banana.png"
},
{
"path": ".\\MasterDetailPage\\Images\\60Lemon.png"
},
{
"path": ".\\MasterDetailPage\\Images\\60Mint.png"
},
{
"path": ".\\MasterDetailPage\\Images\\60Orange.png"
},
{
"path": ".\\MasterDetailPage\\Images\\60SauceCaramel.png"
},
{
"path": ".\\MasterDetailPage\\Images\\60SauceChocolate.png"
},
{
"path": ".\\MasterDetailPage\\Images\\60SauceStrawberry.png"
},
{
"path": ".\\MasterDetailPage\\Images\\60SprinklesChocolate.png"
},
{
"path": ".\\MasterDetailPage\\Images\\60SprinklesRainbow.png"
},
{
"path": ".\\MasterDetailPage\\Images\\60SprinklesVanilla.png"
},
{
"path": ".\\MasterDetailPage\\Images\\60Strawberry.png"
},
{
"path": ".\\MasterDetailPage\\Images\\60Vanilla.png"
}
], ],
"symbols": { "symbols": {
"rootNamespace": { "rootNamespace": {

Просмотреть файл

@ -1,192 +0,0 @@
using System.Collections.Generic;
using System.Threading.Tasks;
namespace ItemNamespace.MasterDetailPage
{
public class DessertService
{
public async Task<IEnumerable<DessertModel>> GetDataAsync()
{
await Task.Delay(0);
var data = new List<DessertModel>();
data.Add(new DessertModel
{
Title = "Banana Blast Frozen Yogurt",
Subtitle = "Maecenas class nam praesent cras aenean mauris aliquam nullam aptent accumsan duis nunc curae donec integer auctor sed congue amet",
Picture = "ms-appx:///MasterDetailPage/Images/60Banana.png",
Link = "http://www.adatum.com/",
Category = "Low-fat frozen yogurt",
Description = "Curabitur class aliquam vestibulum nam curae maecenas sed integer cras phasellus suspendisse quisque donec dis praesent accumsan bibendum pellentesque condimentum adipiscing etiam consequat vivamus dictumst aliquam duis convallis scelerisque est parturient ullamcorper aliquet fusce suspendisse nunc hac eleifend amet blandit facilisi condimentum commodo scelerisque faucibus aenean ullamcorper ante mauris dignissim consectetuer nullam lorem vestibulum habitant conubia elementum pellentesque morbi facilisis arcu sollicitudin diam cubilia aptent vestibulum auctor eget dapibus pellentesque inceptos leo egestas interdum nulla consectetuer suspendisse adipiscing pellentesque proin lobortis sollicitudin augue elit mus congue fermentum parturient fringilla euismod feugiat",
});
data.Add(new DessertModel
{
Title = "Lavish Lemon Ice",
Subtitle = "Quisque vivamus bibendum cursus dictum dictumst dis aliquam aliquet etiam lectus eleifend fusce libero ante facilisi ligula est",
Picture = "ms-appx:///MasterDetailPage/Images/60Lemon.png",
Link = "http://www.adventure-works.com/",
Category = "Sorbet",
Description = "Enim cursus nascetur dictum habitasse hendrerit nec gravida vestibulum pellentesque vestibulum adipiscing iaculis erat consectetuer pellentesque parturient lacinia himenaeos pharetra condimentum non sollicitudin eros dolor vestibulum per lectus pellentesque nibh imperdiet laoreet consectetuer placerat libero malesuada pellentesque fames penatibus ligula scelerisque litora nisi luctus vestibulum nisl ullamcorper sed sem natoque suspendisse felis sit condimentum pulvinar nunc posuere magnis vel scelerisque sagittis porttitor potenti tincidunt mattis ipsum adipiscing sollicitudin parturient mauris nam senectus ullamcorper mollis tristique sociosqu suspendisse ultricies montes sed condimentum dis nostra suscipit justo ornare pretium odio pellentesque lacus lorem torquent orci",
});
data.Add(new DessertModel
{
Title = "Marvelous Mint",
Subtitle = "Litora luctus magnis arcu lorem morbi blandit faucibus mattis commodo hac habitant inceptos conubia cubilia nulla mauris diam proin augue eget dolor mollis interdum lobortis",
Picture = "ms-appx:///MasterDetailPage/Images/60Mint.png",
Link = "http://www.adventure-works.com/",
Category = "Gelato",
Description = "Vestibulum vestibulum magna scelerisque ultrices consectetuer vehicula rhoncus pellentesque massa adipiscing platea primis sodales parturient metus sollicitudin morbi vestibulum pellentesque consectetuer pellentesque volutpat rutrum sollicitudin sapien pellentesque vestibulum venenatis consectetuer viverra est aliquam semper hac maecenas integer adipiscing sociis vulputate ullamcorper curabitur pellentesque parturient praesent neque sollicitudin pellentesque vestibulum suspendisse consectetuer leo quisque phasellus pede vestibulum quam pellentesque sollicitudin quis mus adipiscing parturient pellentesque vestibulum",
});
data.Add(new DessertModel
{
Title = "Creamy Orange",
Subtitle = "Leo mus nec nascetur dapibus non fames per felis ipsum pharetra egestas montes elit nostra placerat euismod enim justo ornare feugiat platea pulvinar sed sagittis",
Picture = "ms-appx:///MasterDetailPage/Images/60Orange.png",
Link = "http://www.alpineskihouse.com/",
Category = "Sorbet",
Description = "Consequat condimentum consectetuer vivamus urna vestibulum netus pellentesque cras nec taciti non scelerisque adipiscing parturient tellus sollicitudin per vestibulum pellentesque aliquam convallis ullamcorper nulla porta aliquet accumsan suspendisse duis bibendum nunc condimentum consectetuer pellentesque scelerisque tempor sed dictumst eleifend amet vestibulum sem tempus facilisi ullamcorper adipiscing tortor ante purus parturient sit dignissim vel nam turpis sed sollicitudin elementum arcu vestibulum risus blandit suspendisse faucibus pellentesque commodo dis condimentum consectetuer varius aenean conubia cubilia facilisis velit mauris nullam aptent dapibus habitant",
});
data.Add(new DessertModel
{
Title = "Succulent Strawberry",
Subtitle = "Senectus sem lacus erat sociosqu eros suscipit primis nibh nisi nisl gravida torquent",
Picture = "ms-appx:///MasterDetailPage/Images/60Strawberry.png",
Link = "http://www.baldwinmuseumofscience.com/",
Category = "Sorbet",
Description = "Est auctor inceptos congue interdum egestas scelerisque pellentesque fermentum ullamcorper cursus dictum lectus suspendisse condimentum libero vitae vestibulum lobortis ligula fringilla euismod class scelerisque feugiat habitasse diam litora adipiscing sollicitudin parturient hendrerit curae himenaeos imperdiet ullamcorper suspendisse nascetur hac gravida pharetra eget donec leo mus nec non malesuada vestibulum pellentesque elit penatibus vestibulum per condimentum porttitor sed adipiscing scelerisque ullamcorper etiam iaculis enim tincidunt erat parturient sem vestibulum eros",
});
data.Add(new DessertModel
{
Title = "Very Vanilla",
Subtitle = "Ultrices rutrum sapien vehicula semper lorem volutpat sociis sit maecenas praesent taciti magna nunc odio orci vel tellus nam sed accumsan iaculis dis est",
Picture = "ms-appx:///MasterDetailPage/Images/60Vanilla.png",
Link = "http://www.blueyonderairlines.com/",
Category = "Ice Cream",
Description = "Consectetuer lacinia vestibulum tristique sit adipiscing laoreet fusce nibh suspendisse natoque placerat pulvinar ultricies condimentum scelerisque nisi ullamcorper nisl parturient vel suspendisse nam venenatis nunc lorem sed dis sagittis pellentesque luctus sollicitudin morbi posuere vestibulum potenti magnis pellentesque vulputate mattis mauris mollis consectetuer pellentesque pretium montes vestibulum condimentum nulla adipiscing sollicitudin scelerisque ullamcorper pellentesque odio orci rhoncus pede sodales suspendisse parturient viverra curabitur proin aliquam integer augue quam condimentum quisque senectus quis urna scelerisque nostra phasellus ullamcorper cras duis suspendisse sociosqu dolor vestibulum condimentum consectetuer vivamus est fames felis suscipit hac",
});
data.Add(new DessertModel
{
Title = "Creamy Caramel Frozen Yogurt",
Subtitle = "Maecenas class nam praesent cras aenean mauris aliquam nullam aptent accumsan duis nunc curae donec integer auctor sed congue amet",
Picture = "ms-appx:///MasterDetailPage/Images/60SauceCaramel.png",
Link = "http://www.adatum.com/",
Category = "Low-fat frozen yogurt",
Description = "Curabitur class aliquam vestibulum nam curae maecenas sed integer cras phasellus suspendisse quisque donec dis praesent accumsan bibendum pellentesque condimentum adipiscing etiam consequat vivamus dictumst aliquam duis convallis scelerisque est parturient ullamcorper aliquet fusce suspendisse nunc hac eleifend amet blandit facilisi condimentum commodo scelerisque faucibus aenean ullamcorper ante mauris dignissim consectetuer nullam lorem vestibulum habitant conubia elementum pellentesque morbi facilisis arcu sollicitudin diam cubilia aptent vestibulum auctor eget dapibus pellentesque inceptos leo egestas interdum nulla consectetuer suspendisse adipiscing pellentesque proin lobortis sollicitudin augue elit mus congue fermentum parturient fringilla euismod feugiat",
});
data.Add(new DessertModel
{
Title = "Chocolate Lovers Frozen Yogurt",
Subtitle = "Quisque vivamus bibendum cursus dictum dictumst dis aliquam aliquet etiam lectus eleifend fusce libero ante facilisi ligula est",
Picture = "ms-appx:///MasterDetailPage/Images/60SauceChocolate.png",
Link = "http://www.adventure-works.com/",
Category = "Low-fat frozen yogurt",
Description = "Enim cursus nascetur dictum habitasse hendrerit nec gravida vestibulum pellentesque vestibulum adipiscing iaculis erat consectetuer pellentesque parturient lacinia himenaeos pharetra condimentum non sollicitudin eros dolor vestibulum per lectus pellentesque nibh imperdiet laoreet consectetuer placerat libero malesuada pellentesque fames penatibus ligula scelerisque litora nisi luctus vestibulum nisl ullamcorper sed sem natoque suspendisse felis sit condimentum pulvinar nunc posuere magnis vel scelerisque sagittis porttitor potenti tincidunt mattis ipsum adipiscing sollicitudin parturient mauris nam senectus ullamcorper mollis tristique sociosqu suspendisse ultricies montes sed condimentum dis nostra suscipit justo ornare pretium odio pellentesque lacus lorem torquent orci",
});
data.Add(new DessertModel
{
Title = "Roma Strawberry",
Subtitle = "Litora luctus magnis arcu lorem morbi blandit faucibus mattis commodo hac habitant inceptos conubia cubilia nulla mauris diam proin augue eget dolor mollis interdum lobortis",
Picture = "ms-appx:///MasterDetailPage/Images/60Strawberry.png",
Link = "http://www.adventure-works.com/",
Category = "Gelato",
Description = "Vestibulum vestibulum magna scelerisque ultrices consectetuer vehicula rhoncus pellentesque massa adipiscing platea primis sodales parturient metus sollicitudin morbi vestibulum pellentesque consectetuer pellentesque volutpat rutrum sollicitudin sapien pellentesque vestibulum venenatis consectetuer viverra est aliquam semper hac maecenas integer adipiscing sociis vulputate ullamcorper curabitur pellentesque parturient praesent neque sollicitudin pellentesque vestibulum suspendisse consectetuer leo quisque phasellus pede vestibulum quam pellentesque sollicitudin quis mus adipiscing parturient pellentesque vestibulum",
});
data.Add(new DessertModel
{
Title = "Italian Rainbow",
Subtitle = "Leo mus nec nascetur dapibus non fames per felis ipsum pharetra egestas montes elit nostra placerat euismod enim justo ornare feugiat platea pulvinar sed sagittis",
Picture = "ms-appx:///MasterDetailPage/Images/60SprinklesRainbow.png",
Link = "http://www.alpineskihouse.com/",
Category = "Gelato",
Description = "Consequat condimentum consectetuer vivamus urna vestibulum netus pellentesque cras nec taciti non scelerisque adipiscing parturient tellus sollicitudin per vestibulum pellentesque aliquam convallis ullamcorper nulla porta aliquet accumsan suspendisse duis bibendum nunc condimentum consectetuer pellentesque scelerisque tempor sed dictumst eleifend amet vestibulum sem tempus facilisi ullamcorper adipiscing tortor ante purus parturient sit dignissim vel nam turpis sed sollicitudin elementum arcu vestibulum risus blandit suspendisse faucibus pellentesque commodo dis condimentum consectetuer varius aenean conubia cubilia facilisis velit mauris nullam aptent dapibus habitant",
});
data.Add(new DessertModel
{
Title = "Strawberry",
Subtitle = "Ultrices rutrum sapien vehicula semper lorem volutpat sociis sit maecenas praesent taciti magna nunc odio orci vel tellus nam sed accumsan iaculis dis est",
Picture = "ms-appx:///MasterDetailPage/Images/60Strawberry.png",
Link = "http://www.blueyonderairlines.com/",
Category = "Ice Cream",
Description = "Consectetuer lacinia vestibulum tristique sit adipiscing laoreet fusce nibh suspendisse natoque placerat pulvinar ultricies condimentum scelerisque nisi ullamcorper nisl parturient vel suspendisse nam venenatis nunc lorem sed dis sagittis pellentesque luctus sollicitudin morbi posuere vestibulum potenti magnis pellentesque vulputate mattis mauris mollis consectetuer pellentesque pretium montes vestibulum condimentum nulla adipiscing sollicitudin scelerisque ullamcorper pellentesque odio orci rhoncus pede sodales suspendisse parturient viverra curabitur proin aliquam integer augue quam condimentum quisque senectus quis urna scelerisque nostra phasellus ullamcorper cras duis suspendisse sociosqu dolor vestibulum condimentum consectetuer vivamus est fames felis suscipit hac",
});
data.Add(new DessertModel
{
Title = "Strawberry Frozen Yogurt",
Subtitle = "Maecenas class nam praesent cras aenean mauris aliquam nullam aptent accumsan duis nunc curae donec integer auctor sed congue amet",
Picture = "ms-appx:///MasterDetailPage/Images/60Strawberry.png",
Link = "http://www.adatum.com/",
Category = "Low-fat frozen yogurt",
Description = "Curabitur class aliquam vestibulum nam curae maecenas sed integer cras phasellus suspendisse quisque donec dis praesent accumsan bibendum pellentesque condimentum adipiscing etiam consequat vivamus dictumst aliquam duis convallis scelerisque est parturient ullamcorper aliquet fusce suspendisse nunc hac eleifend amet blandit facilisi condimentum commodo scelerisque faucibus aenean ullamcorper ante mauris dignissim consectetuer nullam lorem vestibulum habitant conubia elementum pellentesque morbi facilisis arcu sollicitudin diam cubilia aptent vestibulum auctor eget dapibus pellentesque inceptos leo egestas interdum nulla consectetuer suspendisse adipiscing pellentesque proin lobortis sollicitudin augue elit mus congue fermentum parturient fringilla euismod feugiat",
});
data.Add(new DessertModel
{
Title = "Bongo Banana",
Subtitle = "Quisque vivamus bibendum cursus dictum dictumst dis aliquam aliquet etiam lectus eleifend fusce libero ante facilisi ligula est",
Picture = "ms-appx:///MasterDetailPage/Images/60Banana.png",
Link = "http://www.adventure-works.com/",
Category = "Sorbet",
Description = "Enim cursus nascetur dictum habitasse hendrerit nec gravida vestibulum pellentesque vestibulum adipiscing iaculis erat consectetuer pellentesque parturient lacinia himenaeos pharetra condimentum non sollicitudin eros dolor vestibulum per lectus pellentesque nibh imperdiet laoreet consectetuer placerat libero malesuada pellentesque fames penatibus ligula scelerisque litora nisi luctus vestibulum nisl ullamcorper sed sem natoque suspendisse felis sit condimentum pulvinar nunc posuere magnis vel scelerisque sagittis porttitor potenti tincidunt mattis ipsum adipiscing sollicitudin parturient mauris nam senectus ullamcorper mollis tristique sociosqu suspendisse ultricies montes sed condimentum dis nostra suscipit justo ornare pretium odio pellentesque lacus lorem torquent orci",
});
data.Add(new DessertModel
{
Title = "Firenze Vanilla",
Subtitle = "Litora luctus magnis arcu lorem morbi blandit faucibus mattis commodo hac habitant inceptos conubia cubilia nulla mauris diam proin augue eget dolor mollis interdum lobortis",
Picture = "ms-appx:///MasterDetailPage/Images/60Vanilla.png",
Link = "http://www.adventure-works.com/",
Category = "Gelato",
Description = "Vestibulum vestibulum magna scelerisque ultrices consectetuer vehicula rhoncus pellentesque massa adipiscing platea primis sodales parturient metus sollicitudin morbi vestibulum pellentesque consectetuer pellentesque volutpat rutrum sollicitudin sapien pellentesque vestibulum venenatis consectetuer viverra est aliquam semper hac maecenas integer adipiscing sociis vulputate ullamcorper curabitur pellentesque parturient praesent neque sollicitudin pellentesque vestibulum suspendisse consectetuer leo quisque phasellus pede vestibulum quam pellentesque sollicitudin quis mus adipiscing parturient pellentesque vestibulum",
});
data.Add(new DessertModel
{
Title = "Choco-wocko",
Subtitle = "Leo mus nec nascetur dapibus non fames per felis ipsum pharetra egestas montes elit nostra placerat euismod enim justo ornare feugiat platea pulvinar sed sagittis",
Picture = "ms-appx:///MasterDetailPage/Images/60SauceChocolate.png",
Link = "http://www.alpineskihouse.com/",
Category = "Sorbet",
Description = "Consequat condimentum consectetuer vivamus urna vestibulum netus pellentesque cras nec taciti non scelerisque adipiscing parturient tellus sollicitudin per vestibulum pellentesque aliquam convallis ullamcorper nulla porta aliquet accumsan suspendisse duis bibendum nunc condimentum consectetuer pellentesque scelerisque tempor sed dictumst eleifend amet vestibulum sem tempus facilisi ullamcorper adipiscing tortor ante purus parturient sit dignissim vel nam turpis sed sollicitudin elementum arcu vestibulum risus blandit suspendisse faucibus pellentesque commodo dis condimentum consectetuer varius aenean conubia cubilia facilisis velit mauris nullam aptent dapibus habitant",
});
data.Add(new DessertModel
{
Title = "Chocolate",
Subtitle = "Ultrices rutrum sapien vehicula semper lorem volutpat sociis sit maecenas praesent taciti magna nunc odio orci vel tellus nam sed accumsan iaculis dis est",
Picture = "ms-appx:///MasterDetailPage/Images/60SauceChocolate.png",
Link = "http://www.blueyonderairlines.com/",
Category = "Ice Cream",
Description = "Consectetuer lacinia vestibulum tristique sit adipiscing laoreet fusce nibh suspendisse natoque placerat pulvinar ultricies condimentum scelerisque nisi ullamcorper nisl parturient vel suspendisse nam venenatis nunc lorem sed dis sagittis pellentesque luctus sollicitudin morbi posuere vestibulum potenti magnis pellentesque vulputate mattis mauris mollis consectetuer pellentesque pretium montes vestibulum condimentum nulla adipiscing sollicitudin scelerisque ullamcorper pellentesque odio orci rhoncus pede sodales suspendisse parturient viverra curabitur proin aliquam integer augue quam condimentum quisque senectus quis urna scelerisque nostra phasellus ullamcorper cras duis suspendisse sociosqu dolor vestibulum condimentum consectetuer vivamus est fames felis suscipit hac",
});
return data;
}
}
}

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 1.8 KiB

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 2.6 KiB

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 2.6 KiB

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 2.6 KiB

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 2.1 KiB

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 2.1 KiB

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 2.2 KiB

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 4.5 KiB

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 5.3 KiB

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 3.8 KiB

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 2.3 KiB

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 3.2 KiB

Просмотреть файл

@ -1,114 +0,0 @@
<Page
x:Class="ItemNamespace.MasterDetailPage.MasterDetailPagePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:i="using:Microsoft.Xaml.Interactivity"
mc:Ignorable="d">
<Page.Resources>
<Thickness x:Key="ContainerMargin">24,0</Thickness>
<Thickness x:Key="PageHeaderMargin">24,12</Thickness>
<Thickness x:Key="LargeTopMargin">0,16,0,0</Thickness>
<Thickness x:Key="MediumTopMargin">0,8,0,0</Thickness>
<Thickness x:Key="SmallTopMargin">0,4,0,0</Thickness>
<Thickness x:Key="ListItemMargin">12</Thickness>
<Thickness x:Key="ListTextMargin">12,-9,0,0</Thickness>
<Style TargetType="Image" x:Key="ThumbnailStyle">
<Setter Property="Width" Value="80"/>
<Setter Property="Height" Value="80"/>
<Setter Property="Stretch" Value="UniformToFill"/>
</Style>
</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="cd0.Width" Value="*"/>
<Setter Target="cd1.Width" Value="0"/>
<Setter Target="detailGrid.(Grid.Column)" Value="0"/>
</VisualState.Setters>
</VisualState>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="900"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="cd0.Width" Value="Auto"/>
<Setter Target="cd1.Width" Value="*"/>
<Setter Target="detailGrid.(Grid.Column)" Value="1"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<i:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Loaded">
<core:InvokeCommandAction Command="{Binding LoadDataCommand}"/>
</core:EventTriggerBehavior>
</i:Interaction.Behaviors>
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="cd0" />
<ColumnDefinition x:Name="cd1" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" x:Uid="MasterDetailPage_Title" Margin="{StaticResource PageHeaderMargin}" Style="{ThemeResource HeaderTextBlockStyle}"/>
<Grid Visibility="{Binding MasterVisibility}" Grid.Row="1">
<ListView ItemsSource="{Binding DessertList}" SelectionMode="Single" IsItemClickEnabled="True" SelectedItem="{Binding Selected}">
<i:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="ItemClick">
<core:InvokeCommandAction Command="{Binding ItemClickCommand}"/>
</core:EventTriggerBehavior>
</i:Interaction.Behaviors>
<ListView.ItemTemplate>
<DataTemplate>
<Grid Margin="{StaticResource ListItemMargin}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Grid.Column="0" Source="{Binding Picture}" Style="{StaticResource ThumbnailStyle}" />
<StackPanel Grid.Column="1" Margin="{StaticResource ListTextMargin}">
<TextBlock Text="{Binding Title}" Style="{StaticResource TitleTextBlockStyle}" />
<TextBlock Text="{Binding Category}" Style="{StaticResource SubtitleTextBlockStyle}"/>
</StackPanel>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
<ScrollViewer Grid.Row="1" x:Name="detailGrid" Visibility="{Binding DetailVisibility}">
<StackPanel Margin="{StaticResource ContainerMargin}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Grid.Column="0" Source="{Binding Selected.Picture}" Style="{StaticResource ThumbnailStyle}" />
<StackPanel Grid.Column="1" Margin="{StaticResource ListTextMargin}">
<TextBlock Text="{Binding Selected.Title}" Style="{StaticResource TitleTextBlockStyle}" />
<TextBlock Text="{Binding Selected.Category}" Style="{StaticResource SubtitleTextBlockStyle}"/>
</StackPanel>
</Grid>
<TextBlock Text="{Binding Selected.Subtitle}" Margin="{StaticResource MediumTopMargin}" Style="{StaticResource SubtitleTextBlockStyle}"/>
<TextBlock Text="{Binding Selected.Description}" Margin="{StaticResource SmallTopMargin}" Style="{StaticResource BodyTextBlockStyle}"/>
</StackPanel>
</ScrollViewer>
</Grid>
</Page>

Просмотреть файл

@ -1,12 +0,0 @@
using Windows.UI.Xaml.Controls;
namespace ItemNamespace.MasterDetailPage
{
public sealed partial class MasterDetailPagePage : Page
{
public MasterDetailPagePage()
{
this.InitializeComponent();
}
}
}

Просмотреть файл

@ -1,128 +0,0 @@
using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Input;
using Windows.UI.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace ItemNamespace.MasterDetailPage
{
public class MasterDetailPageViewModel : System.ComponentModel.INotifyPropertyChanged
{
const double UseNavigationWithRequested = 900;
private bool _useNavigation;
private Visibility _masterVisibility;
public Visibility MasterVisibility
{
get { return _masterVisibility; }
set { Set(ref _masterVisibility, value); }
}
private Visibility _detailVisibility = Visibility.Collapsed;
public Visibility DetailVisibility
{
get { return _detailVisibility; }
set { Set(ref _detailVisibility, value); }
}
private DessertModel _selected;
public DessertModel Selected
{
get { return _selected; }
set { Set(ref _selected, value); }
}
public ICommand LoadDataCommand { get; private set; }
public ICommand ItemClickCommand { get; private set; }
public ObservableCollection<DessertModel> DessertList { get; private set; } = new ObservableCollection<DessertModel>();
public MasterDetailPageViewModel()
{
this._useNavigation = Window.Current.Bounds.Width < UseNavigationWithRequested;
LoadDataCommand = new RelayCommand(async () => { await LoadDataAsync(); });
ItemClickCommand = new RelayCommand<ItemClickEventArgs>(OnItemClick);
Window.Current.SizeChanged += OnWindowSizeChanged;
SetGoBack();
}
private void OnWindowSizeChanged(object sender, WindowSizeChangedEventArgs e)
{
var newWidth = e.Size.Width;
if (!this._useNavigation && newWidth < UseNavigationWithRequested)
{
//Enter on navigation master detail
this.MasterVisibility = Visibility.Visible;
this.DetailVisibility = Visibility.Collapsed;
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
}
else if (this._useNavigation && newWidth >= UseNavigationWithRequested)
{
//Enter on full screen master detail
this.MasterVisibility = Visibility.Visible;
this.DetailVisibility = Visibility.Visible;
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
}
this._useNavigation = newWidth < UseNavigationWithRequested;
}
private async Task LoadDataAsync()
{
this.DessertList.Clear();
var service = new DessertService();
var data = await service.GetDataAsync();
foreach (var item in data)
{
this.DessertList.Add(item);
}
if (Window.Current.Bounds.Width >= UseNavigationWithRequested)
{
Selected = DessertList.First();
NavigateToDetail();
}
}
private void OnItemClick(ItemClickEventArgs args)
{
DessertModel item = args?.ClickedItem as DessertModel;
if (item != null)
{
Selected = item;
NavigateToDetail();
}
}
private void NavigateToDetail()
{
this.DetailVisibility = Visibility.Visible;
if (this._useNavigation)
{
this.MasterVisibility = Visibility.Collapsed;
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
}
}
private void SetGoBack()
{
if (SystemNavigationManager.GetForCurrentView() != null)
{
SystemNavigationManager.GetForCurrentView().BackRequested += ((sender, e) =>
{
if (DetailVisibility == Visibility.Visible)
{
this.MasterVisibility = Visibility.Visible;
this.DetailVisibility = Visibility.Collapsed;
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
e.Handled = true;
}
});
}
}
}
}

Просмотреть файл

@ -1,10 +1,9 @@
namespace ItemNamespace.MasterDetailPage namespace ItemNamespace.Model
{ {
public class DessertModel public class SampleModel
{ {
public string Title { get; set; } public string Title { get; set; }
public string Category { get; set; } public string Category { get; set; }
public string Picture { get; set; }
public string Subtitle { get; set; } public string Subtitle { get; set; }
public string Link { get; set; } public string Link { get; set; }
public string Description { get; set; } public string Description { get; set; }

Просмотреть файл

@ -0,0 +1,35 @@
using ItemNamespace.Model;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace ItemNamespace.Services
{
public class SampleModelService
{
public async Task<IEnumerable<SampleModel>> GetDataAsync()
{
await Task.Delay(0);
var data = new List<SampleModel>();
data.Add(new SampleModel
{
Title = "Lorem ipsum dolor sit amet",
Subtitle = "Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua",
Link = "http://www.adatum.com/",
Category = "Consectetur Adipiscing",
Description = "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus",
});
data.Add(new SampleModel
{
Title = "Sed ut perspiciatis unde",
Subtitle = "Sit voluptatem accusantium doloremque laudantium, totam rem aperiam",
Link = "http://www.adventure-works.com/",
Category = "Iste Natus",
Description = "Eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?. omnis voluptas assumenda est, omnis dolor repellendus",
});
return data;
}
}
}

Просмотреть файл

@ -0,0 +1,86 @@
<Page
x:Class="ItemNamespace.View.MasterDetailPagePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:i="using:Microsoft.Xaml.Interactivity"
Loaded="OnLoaded"
mc:Ignorable="d">
<Page.Resources>
<Thickness x:Key="ContainerMargin">24,0</Thickness>
<Thickness x:Key="PageHeaderMargin">24,12</Thickness>
<Thickness x:Key="LargeTopMargin">0,16,0,0</Thickness>
<Thickness x:Key="MediumTopMargin">0,8,0,0</Thickness>
<Thickness x:Key="SmallTopMargin">0,4,0,0</Thickness>
<Thickness x:Key="ListItemMargin">8</Thickness>
</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="visualStateGroup" CurrentStateChanged="OnWindowStateChanged">
<VisualState x:Name="NarrowState">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="cd0.Width" Value="*" />
<Setter Target="cd1.Width" Value="0" />
<Setter Target="detailGrid.(Grid.Column)" Value="0" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="DefaultState">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="640" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="cd0.Width" Value="296" />
<Setter Target="cd1.Width" Value="*" />
<Setter Target="detailGrid.(Grid.Column)" Value="1" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="cd0" />
<ColumnDefinition x:Name="cd1" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" x:Uid="MasterDetailPage_Title" Margin="{StaticResource PageHeaderMargin}" Style="{ThemeResource HeaderTextBlockStyle}" />
<Grid Visibility="{Binding MasterVisibility}" Grid.Row="1">
<ListView ItemsSource="{Binding SampleItems}" SelectionMode="Single" IsItemClickEnabled="True" SelectedItem="{Binding Selected}">
<i:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="ItemClick">
<core:InvokeCommandAction Command="{Binding ItemClickCommand}" />
</core:EventTriggerBehavior>
</i:Interaction.Behaviors>
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Margin="{StaticResource ListItemMargin}">
<TextBlock Text="{Binding Title}" Style="{StaticResource SubtitleTextBlockStyle}" />
<TextBlock Text="{Binding Category}" Style="{StaticResource BodyTextBlockStyle}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
<ScrollViewer Grid.Row="1" x:Name="detailGrid" Visibility="{Binding DetailVisibility}">
<StackPanel Margin="{StaticResource ContainerMargin}">
<TextBlock Text="{Binding Selected.Title}" Style="{StaticResource TitleTextBlockStyle}" />
<TextBlock Text="{Binding Selected.Category}" Style="{StaticResource SubtitleTextBlockStyle}" />
<TextBlock Text="{Binding Selected.Subtitle}" Margin="{StaticResource MediumTopMargin}" Style="{StaticResource SubtitleTextBlockStyle}" />
<TextBlock Text="{Binding Selected.Description}" Margin="{StaticResource SmallTopMargin}" Style="{StaticResource BodyTextBlockStyle}" />
</StackPanel>
</ScrollViewer>
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,23 @@
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace ItemNamespace.View
{
public sealed partial class MasterDetailPagePage : Page
{
public MasterDetailPagePage()
{
this.InitializeComponent();
}
private void OnWindowStateChanged(object sender, VisualStateChangedEventArgs e)
{
ViewModel.UpdateWindowState(e);
}
private async void OnLoaded(object sender, RoutedEventArgs e)
{
await ViewModel.LoadDataAsync(visualStateGroup.CurrentState);
}
}
}

Просмотреть файл

@ -0,0 +1,121 @@
using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Input;
using Windows.UI.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using ItemNamespace.Model;
using ItemNamespace.Services;
namespace ItemNamespace.ViewModel
{
public class MasterDetailPageViewModel : System.ComponentModel.INotifyPropertyChanged
{
const string NarrowStateName = "NarrowState";
const string DefaultStateName = "DefaultState";
private VisualState _currentState;
private Visibility _masterVisibility;
public Visibility MasterVisibility
{
get { return _masterVisibility; }
set { Set(ref _masterVisibility, value); }
}
private Visibility _detailVisibility = Visibility.Collapsed;
public Visibility DetailVisibility
{
get { return _detailVisibility; }
set { Set(ref _detailVisibility, value); }
}
private SampleModel _selected;
public SampleModel Selected
{
get { return _selected; }
set { Set(ref _selected, value); }
}
public ICommand ItemClickCommand { get; private set; }
public ObservableCollection<SampleModel> SampleItems { get; private set; } = new ObservableCollection<SampleModel>();
public MasterDetailPageViewModel()
{
ItemClickCommand = new RelayCommand<ItemClickEventArgs>(OnItemClick);
SetGoBack();
}
public async Task LoadDataAsync(VisualState currentState)
{
_currentState = currentState;
SampleItems.Clear();
var service = new SampleModelService();
var data = await service.GetDataAsync();
foreach (var item in data)
{
SampleItems.Add(item);
}
Selected = SampleItems.First();
NavigateToDetail();
}
public void UpdateWindowState(VisualStateChangedEventArgs args)
{
_currentState = args.NewState;
if (args.OldState.Name == NarrowStateName && args.NewState.Name == DefaultStateName)
{
MasterVisibility = Visibility.Visible;
DetailVisibility = Visibility.Visible;
}
else
{
MasterVisibility = Visibility.Visible;
DetailVisibility = Visibility.Collapsed;
}
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
}
private void OnItemClick(ItemClickEventArgs args)
{
SampleModel item = args?.ClickedItem as SampleModel;
if (item != null)
{
Selected = item;
NavigateToDetail();
}
}
private void NavigateToDetail()
{
DetailVisibility = Visibility.Visible;
if (_currentState.Name == NarrowStateName)
{
MasterVisibility = Visibility.Collapsed;
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
}
}
private void SetGoBack()
{
if (SystemNavigationManager.GetForCurrentView() != null)
{
SystemNavigationManager.GetForCurrentView().BackRequested += ((sender, e) =>
{
if (DetailVisibility == Visibility.Visible)
{
MasterVisibility = Visibility.Visible;
DetailVisibility = Visibility.Collapsed;
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
e.Handled = true;
}
});
}
}
}
}

Просмотреть файл

@ -21,13 +21,13 @@
"preferNameDirectory": true, "preferNameDirectory": true,
"PrimaryOutputs": [ "PrimaryOutputs": [
{ {
"path": ".\\SettingsPage\\SettingsPagePage.xaml" "path": ".\\View\\SettingsPagePage.xaml"
}, },
{ {
"path": ".\\SettingsPage\\SettingsPagePage.xaml.cs" "path": ".\\View\\SettingsPagePage.xaml.cs"
}, },
{ {
"path": ".\\SettingsPage\\SettingsPageViewModel.cs" "path": ".\\ViewModel\\SettingsPageViewModel.cs"
}, },
{ {
"path": ".\\Services\\ThemeSelectorService.cs" "path": ".\\Services\\ThemeSelectorService.cs"

Просмотреть файл

@ -1,4 +1,4 @@
private async Task InitializeAsync() private async Task StartupAsync()
{ {
Services.ThemeSelectorService.SetRequestedTheme(); Services.ThemeSelectorService.SetRequestedTheme();
} }

Просмотреть файл

@ -5,18 +5,12 @@ using RootNamespace.Extensions;
namespace RootNamespace.Services namespace RootNamespace.Services
{ {
public enum Theme
{
Light,
Dark
}
public static class ThemeSelectorService public static class ThemeSelectorService
{ {
private const string SettingsKey = "RequestedTheme"; private const string SettingsKey = "RequestedTheme";
public static bool IsLightThemeEnabled => Theme == Theme.Light; public static bool IsLightThemeEnabled => Theme == ElementTheme.Light;
public static Theme Theme { get; set; } public static ElementTheme Theme { get; set; }
static ThemeSelectorService() static ThemeSelectorService()
{ {
@ -25,46 +19,48 @@ namespace RootNamespace.Services
public static void SwitchTheme() public static void SwitchTheme()
{ {
if (Theme == Theme.Dark) if (Theme == ElementTheme.Dark)
{ {
SetTheme(Theme.Light); SetTheme(ElementTheme.Light);
} }
else else
{ {
SetTheme(Theme.Dark); SetTheme(ElementTheme.Dark);
} }
} }
public static void SetTheme(Theme theme)
public static void SetTheme(ElementTheme theme)
{ {
Theme = theme; Theme = theme;
SetRequestedTheme(); SetRequestedTheme();
SaveThemeInSettings(Theme); SaveThemeInSettings(Theme);
} }
public static void SetRequestedTheme() public static void SetRequestedTheme()
{ {
var elementTheme = Theme == Theme.Dark ? ElementTheme.Dark : ElementTheme.Light;
var frameworkElement = Window.Current.Content as FrameworkElement; var frameworkElement = Window.Current.Content as FrameworkElement;
if (frameworkElement != null) if (frameworkElement != null)
{ {
frameworkElement.RequestedTheme = elementTheme; frameworkElement.RequestedTheme = Theme;
} }
} }
private static Theme LoadThemeFromSettings() private static ElementTheme LoadThemeFromSettings()
{ {
Theme cacheTheme = Theme.Light; ElementTheme cacheTheme = ElementTheme.Light;
string themeName = ApplicationData.Current.LocalSettings.Read<string>(SettingsKey); string themeName = ApplicationData.Current.LocalSettings.Read<string>(SettingsKey);
if (String.IsNullOrEmpty(themeName)) if (String.IsNullOrEmpty(themeName))
{ {
cacheTheme = Application.Current.RequestedTheme == ApplicationTheme.Dark ? Theme.Dark : Theme.Light; cacheTheme = Application.Current.RequestedTheme == ApplicationTheme.Dark ? ElementTheme.Dark : ElementTheme.Light;
} }
else else
{ {
Enum.TryParse<Theme>(themeName, out cacheTheme); Enum.TryParse<ElementTheme>(themeName, out cacheTheme);
} }
return cacheTheme; return cacheTheme;
} }
private static void SaveThemeInSettings(Theme theme)
private static void SaveThemeInSettings(ElementTheme theme)
{ {
ApplicationData.Current.LocalSettings.Save<string>(SettingsKey, theme.ToString()); ApplicationData.Current.LocalSettings.Save<string>(SettingsKey, theme.ToString());
} }

Просмотреть файл

@ -1,5 +1,5 @@
<Page <Page
x:Class="ItemNamespace.SettingsPage.SettingsPagePage" x:Class="ItemNamespace.View.SettingsPagePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

Просмотреть файл

@ -1,6 +1,6 @@
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
namespace ItemNamespace.SettingsPage namespace ItemNamespace.View
{ {
public sealed partial class SettingsPagePage : Page public sealed partial class SettingsPagePage : Page
{ {

Просмотреть файл

@ -5,7 +5,7 @@ using Windows.UI.Xaml;
using Windows.Storage; using Windows.Storage;
using RootNamespace.Services; using RootNamespace.Services;
namespace ItemNamespace.SettingsPage namespace ItemNamespace.ViewModel
{ {
public class SettingsPageViewModel : System.ComponentModel.INotifyPropertyChanged public class SettingsPageViewModel : System.ComponentModel.INotifyPropertyChanged
{ {

Просмотреть файл

@ -20,13 +20,13 @@
"preferNameDirectory": true, "preferNameDirectory": true,
"PrimaryOutputs": [ "PrimaryOutputs": [
{ {
"path": ".\\TabbedPivotPage\\TabbedPivotPagePage.xaml" "path": ".\\View\\TabbedPivotPagePage.xaml"
}, },
{ {
"path": ".\\TabbedPivotPage\\TabbedPivotPagePage.xaml.cs" "path": ".\\View\\TabbedPivotPagePage.xaml.cs"
}, },
{ {
"path": ".\\TabbedPivotPage\\TabbedPivotPageViewModel.cs" "path": ".\\ViewModel\\TabbedPivotPageViewModel.cs"
} }
], ],
"symbols": { "symbols": {

Просмотреть файл

@ -1,5 +1,5 @@
<Page <Page
x:Class="ItemNamespace.TabbedPivotPage.TabbedPivotPagePage" x:Class="ItemNamespace.View.TabbedPivotPagePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

Просмотреть файл

@ -1,6 +1,6 @@
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
namespace ItemNamespace.TabbedPivotPage namespace ItemNamespace.View
{ {
public sealed partial class TabbedPivotPagePage : Page public sealed partial class TabbedPivotPagePage : Page
{ {

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше