TitleBar Sample
|
@ -0,0 +1,40 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.22823.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TitleBar", "TitleBar\TitleBar.csproj", "{D0DEE5AA-2B94-4C59-8FAA-8588D9D6F04E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|ARM = Debug|ARM
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|ARM = Release|ARM
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D0DEE5AA-2B94-4C59-8FAA-8588D9D6F04E}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{D0DEE5AA-2B94-4C59-8FAA-8588D9D6F04E}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{D0DEE5AA-2B94-4C59-8FAA-8588D9D6F04E}.Debug|ARM.Deploy.0 = Debug|ARM
|
||||
{D0DEE5AA-2B94-4C59-8FAA-8588D9D6F04E}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{D0DEE5AA-2B94-4C59-8FAA-8588D9D6F04E}.Debug|x64.Build.0 = Debug|x64
|
||||
{D0DEE5AA-2B94-4C59-8FAA-8588D9D6F04E}.Debug|x64.Deploy.0 = Debug|x64
|
||||
{D0DEE5AA-2B94-4C59-8FAA-8588D9D6F04E}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{D0DEE5AA-2B94-4C59-8FAA-8588D9D6F04E}.Debug|x86.Build.0 = Debug|x86
|
||||
{D0DEE5AA-2B94-4C59-8FAA-8588D9D6F04E}.Debug|x86.Deploy.0 = Debug|x86
|
||||
{D0DEE5AA-2B94-4C59-8FAA-8588D9D6F04E}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{D0DEE5AA-2B94-4C59-8FAA-8588D9D6F04E}.Release|ARM.Build.0 = Release|ARM
|
||||
{D0DEE5AA-2B94-4C59-8FAA-8588D9D6F04E}.Release|ARM.Deploy.0 = Release|ARM
|
||||
{D0DEE5AA-2B94-4C59-8FAA-8588D9D6F04E}.Release|x64.ActiveCfg = Release|x64
|
||||
{D0DEE5AA-2B94-4C59-8FAA-8588D9D6F04E}.Release|x64.Build.0 = Release|x64
|
||||
{D0DEE5AA-2B94-4C59-8FAA-8588D9D6F04E}.Release|x64.Deploy.0 = Release|x64
|
||||
{D0DEE5AA-2B94-4C59-8FAA-8588D9D6F04E}.Release|x86.ActiveCfg = Release|x86
|
||||
{D0DEE5AA-2B94-4C59-8FAA-8588D9D6F04E}.Release|x86.Build.0 = Release|x86
|
||||
{D0DEE5AA-2B94-4C59-8FAA-8588D9D6F04E}.Release|x86.Deploy.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,19 @@
|
|||
<Application
|
||||
x:Class="TitleBar.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:TitleBar"
|
||||
RequestedTheme="Light"
|
||||
xmlns:locator="using:TitleBar.ViewModels.Base">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/Themes/Colors.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<!-- ViewModelLocator -->
|
||||
<locator:ViewModelLocator x:Key="Locator" />
|
||||
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
|
@ -0,0 +1,102 @@
|
|||
using System;
|
||||
using Windows.ApplicationModel;
|
||||
using Windows.ApplicationModel.Activation;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
namespace TitleBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides application-specific behavior to supplement the default Application class.
|
||||
/// </summary>
|
||||
sealed partial class App : Application
|
||||
{
|
||||
/// <summary>
|
||||
/// Allows tracking page views, exceptions and other telemetry through the Microsoft Application Insights service.
|
||||
/// </summary>
|
||||
public static Microsoft.ApplicationInsights.TelemetryClient TelemetryClient;
|
||||
|
||||
/// <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()
|
||||
{
|
||||
TelemetryClient = new Microsoft.ApplicationInsights.TelemetryClient();
|
||||
|
||||
this.InitializeComponent();
|
||||
this.Suspending += OnSuspending;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the application is launched normally by the end user. Other entry points
|
||||
/// will be used such as when the application is launched to open a specific file.
|
||||
/// </summary>
|
||||
/// <param name="e">Details about the launch request and process.</param>
|
||||
protected override void OnLaunched(LaunchActivatedEventArgs e)
|
||||
{
|
||||
|
||||
#if DEBUG
|
||||
if (System.Diagnostics.Debugger.IsAttached)
|
||||
{
|
||||
this.DebugSettings.EnableFrameRateCounter = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
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();
|
||||
|
||||
rootFrame.NavigationFailed += OnNavigationFailed;
|
||||
|
||||
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
|
||||
{
|
||||
//TODO: Load state from previously suspended application
|
||||
}
|
||||
|
||||
// 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
|
||||
rootFrame.Navigate(typeof(MainView), e.Arguments);
|
||||
}
|
||||
// Ensure the current window is active
|
||||
Window.Current.Activate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when Navigation to a certain page fails
|
||||
/// </summary>
|
||||
/// <param name="sender">The Frame which failed navigation</param>
|
||||
/// <param name="e">Details about the navigation failure</param>
|
||||
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
|
||||
{
|
||||
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
|
||||
}
|
||||
|
||||
/// <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 void OnSuspending(object sender, SuspendingEventArgs e)
|
||||
{
|
||||
var deferral = e.SuspendingOperation.GetDeferral();
|
||||
//TODO: Save application state and stop any background activity
|
||||
deferral.Complete();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
|
||||
<!--
|
||||
Learn more about Application Insights configuration with ApplicationInsights.config here:
|
||||
http://go.microsoft.com/fwlink/?LinkID=513840
|
||||
|
||||
Note: If not present, please add <InstrumentationKey>Your Key</InstrumentationKey> to the top of this file.
|
||||
-->
|
||||
<TelemetryModules>
|
||||
<Add Type="Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule, Microsoft.ApplicationInsights"/>
|
||||
<Add Type="Microsoft.ApplicationInsights.Extensibility.Windows.SessionTelemetryModule, Microsoft.ApplicationInsights.Extensibility.Windows"/>
|
||||
<Add Type="Microsoft.ApplicationInsights.Extensibility.Windows.PageViewTelemetryModule, Microsoft.ApplicationInsights.Extensibility.Windows"/>
|
||||
<Add Type="Microsoft.ApplicationInsights.Extensibility.Windows.UnhandledExceptionTelemetryModule, Microsoft.ApplicationInsights.Extensibility.Windows"/>
|
||||
</TelemetryModules>
|
||||
<TelemetryChannel Type="Microsoft.ApplicationInsights.Channel.PersistenceChannel, Microsoft.ApplicationInsights.PersistenceChannel"/>
|
||||
<ContextInitializers>
|
||||
<Add Type="Microsoft.ApplicationInsights.Extensibility.ComponentContextInitializer, Microsoft.ApplicationInsights"/>
|
||||
<Add Type="Microsoft.ApplicationInsights.Extensibility.DeviceContextInitializer, Microsoft.ApplicationInsights"/>
|
||||
</ContextInitializers>
|
||||
<TelemetryInitializers>
|
||||
<Add Type="Microsoft.ApplicationInsights.Extensibility.Windows.UserContextInitializer, Microsoft.ApplicationInsights.Extensibility.Windows"/>
|
||||
</TelemetryInitializers>
|
||||
</ApplicationInsights>
|
После Ширина: | Высота: | Размер: 801 B |
После Ширина: | Высота: | Размер: 329 B |
После Ширина: | Высота: | Размер: 2.1 KiB |
После Ширина: | Высота: | Размер: 429 B |
После Ширина: | Высота: | Размер: 2.1 KiB |
|
@ -0,0 +1,125 @@
|
|||
namespace TitleBar.Behaviors
|
||||
{
|
||||
using System;
|
||||
using Microsoft.Xaml.Interactivity;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI;
|
||||
using Windows.UI.ViewManagement;
|
||||
|
||||
public class TitleBarBehavior : DependencyObject, IBehavior
|
||||
{
|
||||
public DependencyObject AssociatedObject { get; private set; }
|
||||
|
||||
public void Attach(DependencyObject associatedObject)
|
||||
{
|
||||
var titleBar = associatedObject as UIElement;
|
||||
if (titleBar == null)
|
||||
throw new ArgumentException(
|
||||
"TitleBarBehavior can be attached only to UIElement!");
|
||||
|
||||
Window.Current.SetTitleBar(titleBar);
|
||||
|
||||
AssociatedObject = associatedObject;
|
||||
}
|
||||
|
||||
public void Detach()
|
||||
{
|
||||
AssociatedObject = null;
|
||||
}
|
||||
|
||||
public Color BackgroundColor
|
||||
{
|
||||
get { return (Color)GetValue(BackgroundColorProperty); }
|
||||
set { SetValue(BackgroundColorProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty BackgroundColorProperty =
|
||||
DependencyProperty.Register("BackgroundColor",
|
||||
typeof(Color),
|
||||
typeof(TitleBarBehavior),
|
||||
new PropertyMetadata(false, OnBackgroundColorChanged));
|
||||
|
||||
private static void OnBackgroundColorChanged(DependencyObject d,
|
||||
DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var applicationView = ApplicationView.GetForCurrentView();
|
||||
applicationView.TitleBar.BackgroundColor = (Color)e.NewValue;
|
||||
}
|
||||
|
||||
public string Title
|
||||
{
|
||||
get { return (string)GetValue(TitleProperty); }
|
||||
set { SetValue(TitleProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty TitleProperty =
|
||||
DependencyProperty.Register("Title",
|
||||
typeof(string),
|
||||
typeof(TitleBarBehavior),
|
||||
new PropertyMetadata(string.Empty, OnTitleChanged));
|
||||
|
||||
private static void OnTitleChanged(DependencyObject d,
|
||||
DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var applicationView = ApplicationView.GetForCurrentView();
|
||||
applicationView.Title = (string)e.NewValue;
|
||||
}
|
||||
|
||||
public Color ForegroundColor
|
||||
{
|
||||
get { return (Color)GetValue(ForegroundColorProperty); }
|
||||
set { SetValue(ForegroundColorProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ForegroundColorProperty =
|
||||
DependencyProperty.Register("ForegroundColor",
|
||||
typeof(Color),
|
||||
typeof(TitleBarBehavior),
|
||||
new PropertyMetadata(false, OnForegroundColorChanged));
|
||||
|
||||
private static void OnForegroundColorChanged(DependencyObject d,
|
||||
DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var applicationView = ApplicationView.GetForCurrentView();
|
||||
applicationView.TitleBar.ForegroundColor = (Color)e.NewValue;
|
||||
}
|
||||
|
||||
public Color ButtonForegroundColor
|
||||
{
|
||||
get { return (Color)GetValue(ButtonForegroundColorProperty); }
|
||||
set { SetValue(ButtonForegroundColorProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ButtonForegroundColorProperty =
|
||||
DependencyProperty.Register("ButtonForegroundColor",
|
||||
typeof(Color),
|
||||
typeof(TitleBarBehavior),
|
||||
new PropertyMetadata(false, OnButtonForegroundColorChanged));
|
||||
|
||||
private static void OnButtonForegroundColorChanged(DependencyObject d,
|
||||
DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var applicationView = ApplicationView.GetForCurrentView();
|
||||
applicationView.TitleBar.ButtonForegroundColor = (Color)e.NewValue;
|
||||
}
|
||||
|
||||
public Color ButtonBackgroundColor
|
||||
{
|
||||
get { return (Color)GetValue(ButtonBackgroundColorProperty); }
|
||||
set { SetValue(ButtonBackgroundColorProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ButtonBackgroundColorProperty =
|
||||
DependencyProperty.Register("ButtonBackgroundColor",
|
||||
typeof(Color),
|
||||
typeof(TitleBarBehavior),
|
||||
new PropertyMetadata(false, OnButtonBackgroundColorChanged));
|
||||
|
||||
private static void OnButtonBackgroundColorChanged(DependencyObject d,
|
||||
DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var applicationView = ApplicationView.GetForCurrentView();
|
||||
applicationView.TitleBar.ButtonBackgroundColor = (Color)e.NewValue;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<Package
|
||||
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
|
||||
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
|
||||
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
|
||||
IgnorableNamespaces="uap mp">
|
||||
|
||||
<Identity
|
||||
Name="f9687137-e7df-4050-b821-9f490e92d897"
|
||||
Publisher="CN=Javier"
|
||||
Version="1.0.0.0" />
|
||||
|
||||
<mp:PhoneIdentity PhoneProductId="f9687137-e7df-4050-b821-9f490e92d897" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
|
||||
|
||||
<Properties>
|
||||
<DisplayName>TitleBar</DisplayName>
|
||||
<PublisherDisplayName>Javier</PublisherDisplayName>
|
||||
<Logo>Assets\StoreLogo.png</Logo>
|
||||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.10069.0" MaxVersionTested="10.0.10069.0" />
|
||||
</Dependencies>
|
||||
|
||||
<Resources>
|
||||
<Resource Language="x-generate"/>
|
||||
</Resources>
|
||||
|
||||
<Applications>
|
||||
<Application Id="App"
|
||||
Executable="$targetnametoken$.exe"
|
||||
EntryPoint="TitleBar.App">
|
||||
<uap:VisualElements
|
||||
DisplayName="TitleBar"
|
||||
Square150x150Logo="Assets\Logo.png"
|
||||
Square44x44Logo="Assets\SmallLogo.png"
|
||||
Description="TitleBar"
|
||||
BackgroundColor="#464646">
|
||||
<uap:SplashScreen Image="Assets\SplashScreen.png" />
|
||||
</uap:VisualElements>
|
||||
</Application>
|
||||
</Applications>
|
||||
|
||||
<Capabilities>
|
||||
<Capability Name="internetClient" />
|
||||
</Capabilities>
|
||||
</Package>
|
|
@ -0,0 +1,29 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("TitleBar")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("TitleBar")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: ComVisible(false)]
|
|
@ -0,0 +1,31 @@
|
|||
<!--
|
||||
This file contains Runtime Directives used by .NET Native. The defaults here are suitable for most
|
||||
developers. However, you can modify these parameters to modify the behavior of the .NET Native
|
||||
optimizer.
|
||||
|
||||
Runtime Directives are documented at http://go.microsoft.com/fwlink/?LinkID=391919
|
||||
|
||||
To fully enable reflection for App1.MyClass and all of its public/private members
|
||||
<Type Name="App1.MyClass" Dynamic="Required All"/>
|
||||
|
||||
To enable dynamic creation of the specific instantiation of AppClass<T> over System.Int32
|
||||
<TypeInstantiation Name="App1.AppClass" Arguments="System.Int32" Activate="Required Public" />
|
||||
|
||||
Using the Namespace directive to apply reflection policy to all the types in a particular namespace
|
||||
<Namespace Name="DataClasses.ViewModels" Seralize="All" />
|
||||
-->
|
||||
|
||||
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
|
||||
<Application>
|
||||
<!--
|
||||
An Assembly element with Name="*Application*" applies to all assemblies in
|
||||
the application package. The asterisks are not wildcards.
|
||||
-->
|
||||
<Assembly Name="*Application*" Dynamic="Required All" />
|
||||
|
||||
|
||||
<!-- Add your application specific runtime directives here. -->
|
||||
|
||||
|
||||
</Application>
|
||||
</Directives>
|
|
@ -0,0 +1,9 @@
|
|||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<Color x:Key="WhiteColor">White</Color>
|
||||
<Color x:Key="RedColor">Red</Color>
|
||||
<Color x:Key="BlueColor">Blue</Color>
|
||||
|
||||
</ResourceDictionary>
|
|
@ -0,0 +1,206 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProjectGuid>{D0DEE5AA-2B94-4C59-8FAA-8588D9D6F04E}</ProjectGuid>
|
||||
<OutputType>AppContainerExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TitleBar</RootNamespace>
|
||||
<AssemblyName>TitleBar</AssemblyName>
|
||||
<DefaultLanguage>es-ES</DefaultLanguage>
|
||||
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
|
||||
<TargetPlatformVersion>10.0.10069.0</TargetPlatformVersion>
|
||||
<TargetPlatformMinVersion>10.0.10069.0</TargetPlatformMinVersion>
|
||||
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
|
||||
<EnableDotNetNativeCompatibleProfile>true</EnableDotNetNativeCompatibleProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<PackageCertificateKeyFile>TitleBar_TemporaryKey.pfx</PackageCertificateKeyFile>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\ARM\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UAP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
||||
<OutputPath>bin\ARM\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UAP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UAP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UAP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UAP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UAP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Behaviors\TitleBarBehavior.cs" />
|
||||
<Compile Include="ViewModels\Base\DelegateCommand.cs" />
|
||||
<Compile Include="ViewModels\Base\DelegateCommandAsync.cs" />
|
||||
<Compile Include="ViewModels\Base\ViewModelBase.cs" />
|
||||
<Compile Include="ViewModels\Base\ViewModelLocator.cs" />
|
||||
<Compile Include="ViewModels\MainViewModel.cs" />
|
||||
<Compile Include="Views\Base\PageBase.cs" />
|
||||
<Compile Include="Views\BehaviorView.xaml.cs">
|
||||
<DependentUpon>BehaviorView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\MainView.xaml.cs">
|
||||
<DependentUpon>MainView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AppxManifest Include="Package.appxmanifest">
|
||||
<SubType>Designer</SubType>
|
||||
</AppxManifest>
|
||||
<None Include="ApplicationInsights.config" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="TitleBar_TemporaryKey.pfx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Properties\Default.rd.xml" />
|
||||
<Content Include="Assets\Logo.scale-100.png" />
|
||||
<Content Include="Assets\SmallLogo.scale-100.png" />
|
||||
<Content Include="Assets\SplashScreen.scale-100.png" />
|
||||
<Content Include="Assets\StoreLogo.scale-100.png" />
|
||||
<Content Include="Assets\WideLogo.scale-100.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="Themes\Colors.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Page>
|
||||
<Page Include="Views\BehaviorView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\MainView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.ApplicationInsights, Version=0.14.3.177, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.ApplicationInsights.0.14.3-build00177\lib\portable-win81+wpa81\Microsoft.ApplicationInsights.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.ApplicationInsights.Extensibility.Windows, Version=0.14.3.177, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.ApplicationInsights.WindowsApps.0.14.3-build00177\lib\win81\Microsoft.ApplicationInsights.Extensibility.Windows.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.ApplicationInsights.PersistenceChannel, Version=0.14.3.186, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.ApplicationInsights.PersistenceChannel.0.14.3-build00177\lib\portable-win81+wpa81\Microsoft.ApplicationInsights.PersistenceChannel.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Practices.ServiceLocation, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\CommonServiceLocator.1.2\lib\portable-windows8+net40+sl5+windowsphone8\Microsoft.Practices.ServiceLocation.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Practices.Unity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Unity.3.5.1404.0\lib\win8\Microsoft.Practices.Unity.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Practices.Unity.RegistrationByConvention, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Unity.3.5.1404.0\lib\win8\Microsoft.Practices.Unity.RegistrationByConvention.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.0.0\lib\win8\System.Numerics.Vectors.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics.Vectors.WindowsRuntime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.0.0\lib\win8\System.Numerics.Vectors.WindowsRuntime.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<SDKReference Include="BehaviorsXamlSDKManaged, Version=12.0">
|
||||
<Name>Behaviors SDK %28XAML%29</Name>
|
||||
</SDKReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
|
||||
<Import Project="..\packages\Microsoft.Diagnostics.Tracing.EventSource.Redist.1.1.16-beta\build\portable-net45+win8+wpa81\Microsoft.Diagnostics.Tracing.EventSource.Redist.targets" Condition="Exists('..\packages\Microsoft.Diagnostics.Tracing.EventSource.Redist.1.1.16-beta\build\portable-net45+win8+wpa81\Microsoft.Diagnostics.Tracing.EventSource.Redist.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Diagnostics.Tracing.EventSource.Redist.1.1.16-beta\build\portable-net45+win8+wpa81\Microsoft.Diagnostics.Tracing.EventSource.Redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Diagnostics.Tracing.EventSource.Redist.1.1.16-beta\build\portable-net45+win8+wpa81\Microsoft.Diagnostics.Tracing.EventSource.Redist.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.ApplicationInsights.0.14.3-build00177\build\portable-win81+wpa81\Microsoft.ApplicationInsights.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ApplicationInsights.0.14.3-build00177\build\portable-win81+wpa81\Microsoft.ApplicationInsights.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\Microsoft.ApplicationInsights.0.14.3-build00177\build\portable-win81+wpa81\Microsoft.ApplicationInsights.targets" Condition="Exists('..\packages\Microsoft.ApplicationInsights.0.14.3-build00177\build\portable-win81+wpa81\Microsoft.ApplicationInsights.targets')" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -0,0 +1,131 @@
|
|||
using System;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace TitleBar.ViewModels.Base
|
||||
{
|
||||
/// <summary>
|
||||
/// This class allows us to delegate command execution to viewmodels.
|
||||
/// </summary>
|
||||
public class DelegateCommand : ICommand
|
||||
{
|
||||
private readonly Action _execute;
|
||||
private readonly Func<bool> _canExecute;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor not using canExecute.
|
||||
/// </summary>
|
||||
/// <param name="execute"></param>
|
||||
public DelegateCommand(Action execute) : this(execute, null) { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor using both execute and canExecute.
|
||||
/// </summary>
|
||||
/// <param name="execute"></param>
|
||||
/// <param name="canExecute"></param>
|
||||
public DelegateCommand(Action execute, Func<bool> canExecute)
|
||||
{
|
||||
_execute = execute;
|
||||
_canExecute = canExecute;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is called from XAML to evaluate if the command can be executed.
|
||||
/// </summary>
|
||||
/// <param name="parameter"></param>
|
||||
/// <returns></returns>
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
if (_canExecute != null)
|
||||
return _canExecute();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is called from XAML to execute the command.
|
||||
/// </summary>
|
||||
/// <param name="parameter"></param>
|
||||
public void Execute(object parameter)
|
||||
{
|
||||
_execute();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method allow us to force the execution of CanExecute method to reevaluate execution.
|
||||
/// </summary>
|
||||
public void RaiseCanExecuteChanged()
|
||||
{
|
||||
var tmpHandle = CanExecuteChanged;
|
||||
if (tmpHandle != null)
|
||||
tmpHandle(this, new EventArgs());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This event notify XAML controls using the command to reevaluate the CanExecute of it.
|
||||
/// </summary>
|
||||
public event EventHandler CanExecuteChanged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This class allows us to delegate command execution to viewmodels using a T type as parameter.
|
||||
/// </summary>
|
||||
public class DelegateCommand<T> : ICommand
|
||||
{
|
||||
private readonly Action<T> _execute;
|
||||
private readonly Func<T, bool> _canExecute;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor not using canExecute.
|
||||
/// </summary>
|
||||
/// <param name="execute"></param>
|
||||
public DelegateCommand(Action<T> execute) : this(execute, null) { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor using both execute and canExecute.
|
||||
/// </summary>
|
||||
/// <param name="execute"></param>
|
||||
/// <param name="canExecute"></param>
|
||||
public DelegateCommand(Action<T> execute, Func<T, bool> canExecute)
|
||||
{
|
||||
_execute = execute;
|
||||
_canExecute = canExecute;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is called from XAML to evaluate if the command can be executed.
|
||||
/// </summary>
|
||||
/// <param name="parameter"></param>
|
||||
/// <returns></returns>
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
if (_canExecute != null)
|
||||
return _canExecute((T)parameter);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is called from XAML to execute the command.
|
||||
/// </summary>
|
||||
/// <param name="parameter"></param>
|
||||
public void Execute(object parameter)
|
||||
{
|
||||
_execute((T)parameter);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method allow us to force the execution of CanExecute method to reevaluate execution.
|
||||
/// </summary>
|
||||
public void RaiseCanExecuteChanged()
|
||||
{
|
||||
var tmpHandle = CanExecuteChanged;
|
||||
if (tmpHandle != null)
|
||||
tmpHandle(this, new EventArgs());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This event notify XAML controls using the command to reevaluate the CanExecute of it.
|
||||
/// </summary>
|
||||
public event EventHandler CanExecuteChanged;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace TitleBar.ViewModels.Base
|
||||
{
|
||||
/// <summary>
|
||||
/// This class allows us to delegate command execution to viewmodels.
|
||||
/// This version of the command allow to use async/await.
|
||||
/// </summary>
|
||||
public class DelegateCommandAsync : ICommand
|
||||
{
|
||||
private readonly Func<Task<bool>> _canExecute;
|
||||
private readonly Func<Task> _execute;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor not using canExecute.
|
||||
/// </summary>
|
||||
/// <param name="execute"></param>
|
||||
public DelegateCommandAsync(Func<Task> execute) : this(execute, null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor using both execute and canExecute.
|
||||
/// </summary>
|
||||
/// <param name="execute"></param>
|
||||
/// <param name="canExecute"></param>
|
||||
public DelegateCommandAsync(Func<Task> execute, Func<Task<bool>> canExecute)
|
||||
{
|
||||
_execute = execute;
|
||||
_canExecute = canExecute;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is called from XAML to evaluate if the command can be executed.
|
||||
/// </summary>
|
||||
/// <param name="parameter"></param>
|
||||
/// <returns></returns>
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
if (_canExecute != null)
|
||||
return _canExecute().Result;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is called from XAML to execute the command.
|
||||
/// </summary>
|
||||
/// <param name="parameter"></param>
|
||||
public void Execute(object parameter)
|
||||
{
|
||||
_execute();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This event notify XAML controls using the command to reevaluate the CanExecute of it.
|
||||
/// </summary>
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
/// <summary>
|
||||
/// This method allow us to force the execution of CanExecute method to reevaluate execution.
|
||||
/// </summary>
|
||||
public void RaiseCanExecuteChanged()
|
||||
{
|
||||
EventHandler tmpHandle = CanExecuteChanged;
|
||||
if (tmpHandle != null)
|
||||
tmpHandle(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This class allows us to delegate command execution to viewmodels using a T type as parameter.
|
||||
/// </summary>
|
||||
public class DelegateCommandAsync<T> : ICommand
|
||||
{
|
||||
private readonly Func<T, Task<bool>> _canExecute;
|
||||
private readonly Func<T, Task> _execute;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor not using canExecute.
|
||||
/// </summary>
|
||||
/// <param name="execute"></param>
|
||||
public DelegateCommandAsync(Func<T, Task> execute) : this(execute, null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor using both execute and canExecute.
|
||||
/// </summary>
|
||||
/// <param name="execute"></param>
|
||||
/// <param name="canExecute"></param>
|
||||
public DelegateCommandAsync(Func<T, Task> execute, Func<T, Task<bool>> canExecute)
|
||||
{
|
||||
_execute = execute;
|
||||
_canExecute = canExecute;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is called from XAML to evaluate if the command can be executed.
|
||||
/// </summary>
|
||||
/// <param name="parameter"></param>
|
||||
/// <returns></returns>
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
if (_canExecute != null)
|
||||
return _canExecute((T) parameter).Result;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is called from XAML to execute the command.
|
||||
/// </summary>
|
||||
/// <param name="parameter"></param>
|
||||
public void Execute(object parameter)
|
||||
{
|
||||
_execute((T) parameter);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This event notify XAML controls using the command to reevaluate the CanExecute of it.
|
||||
/// </summary>
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
/// <summary>
|
||||
/// This method allow us to force the execution of CanExecute method to reevaluate execution.
|
||||
/// </summary>
|
||||
public void RaiseCanExecuteChanged()
|
||||
{
|
||||
EventHandler tmpHandle = CanExecuteChanged;
|
||||
if (tmpHandle != null)
|
||||
tmpHandle(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
namespace TitleBar.ViewModels.Base
|
||||
{
|
||||
public abstract class ViewModelBase : INotifyPropertyChanged
|
||||
{
|
||||
private Frame appFrame;
|
||||
private Frame splitViewFrame;
|
||||
private bool isBusy;
|
||||
|
||||
public ViewModelBase()
|
||||
{
|
||||
}
|
||||
|
||||
public Frame AppFrame
|
||||
{
|
||||
get { return appFrame; }
|
||||
}
|
||||
public Frame SplitViewFrame
|
||||
{
|
||||
get { return splitViewFrame; }
|
||||
}
|
||||
|
||||
public bool IsBusy
|
||||
{
|
||||
get { return isBusy; }
|
||||
set
|
||||
{
|
||||
isBusy = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public abstract Task OnNavigatedFrom(NavigationEventArgs args);
|
||||
|
||||
public abstract Task OnNavigatedTo(NavigationEventArgs args);
|
||||
|
||||
public void RaisePropertyChanged([CallerMemberName]string propertyName = "")
|
||||
{
|
||||
var Handler = PropertyChanged;
|
||||
if (Handler != null)
|
||||
Handler(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
internal void SetAppFrame(Frame viewFrame)
|
||||
{
|
||||
appFrame = viewFrame;
|
||||
}
|
||||
|
||||
internal void SetSplitFrame(Frame viewFrame)
|
||||
{
|
||||
splitViewFrame = viewFrame;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
namespace TitleBar.ViewModels.Base
|
||||
{
|
||||
using Microsoft.Practices.Unity;
|
||||
using ViewModels;
|
||||
|
||||
public class ViewModelLocator
|
||||
{
|
||||
readonly IUnityContainer _container;
|
||||
|
||||
public ViewModelLocator()
|
||||
{
|
||||
_container = new UnityContainer();
|
||||
|
||||
// ViewModels
|
||||
_container.RegisterType<MainViewModel>();
|
||||
}
|
||||
|
||||
public MainViewModel MainViewModel
|
||||
{
|
||||
get { return _container.Resolve<MainViewModel>(); }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
namespace TitleBar.ViewModels
|
||||
{
|
||||
using System.Threading.Tasks;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
using Base;
|
||||
using System.Windows.Input;
|
||||
using TitleBar.Views;
|
||||
|
||||
public class MainViewModel : ViewModelBase
|
||||
{
|
||||
private ICommand _navigateCommand;
|
||||
public override Task OnNavigatedFrom(NavigationEventArgs args)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public override Task OnNavigatedTo(NavigationEventArgs args)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public ICommand NavigateCommand
|
||||
{
|
||||
get { return _navigateCommand = _navigateCommand ?? new DelegateCommand(NavigateCommandExecute); }
|
||||
}
|
||||
|
||||
private void NavigateCommandExecute()
|
||||
{
|
||||
AppFrame.Navigate(typeof(BehaviorView));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
namespace TitleBar.Views.Base
|
||||
{
|
||||
using ViewModels.Base;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
public class PageBase : Page
|
||||
{
|
||||
private ViewModelBase _vm;
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
|
||||
_vm = (ViewModelBase)this.DataContext;
|
||||
_vm.SetAppFrame(this.Frame);
|
||||
_vm.OnNavigatedTo(e);
|
||||
}
|
||||
|
||||
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedFrom(e);
|
||||
_vm.OnNavigatedFrom(e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
<base:PageBase
|
||||
x:Class="TitleBar.Views.BehaviorView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:TitleBar.Views"
|
||||
xmlns:base="using:TitleBar.Views.Base"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:i="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:behaviors="using:TitleBar.Behaviors"
|
||||
mc:Ignorable="d"
|
||||
DataContext="{Binding MainViewModel, Source={StaticResource Locator}}">
|
||||
<i:Interaction.Behaviors>
|
||||
<behaviors:TitleBarBehavior
|
||||
Title="Changed from Behavior!"
|
||||
BackgroundColor="{StaticResource RedColor}"
|
||||
ForegroundColor="{StaticResource WhiteColor}"
|
||||
ButtonBackgroundColor="{StaticResource BlueColor}"
|
||||
ButtonForegroundColor="{StaticResource WhiteColor}"/>
|
||||
</i:Interaction.Behaviors>
|
||||
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<StackPanel
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center">
|
||||
<TextBlock Text="Using Behaviors SDK!" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</base:PageBase>
|
|
@ -0,0 +1,12 @@
|
|||
namespace TitleBar.Views
|
||||
{
|
||||
using Base;
|
||||
|
||||
public sealed partial class BehaviorView : PageBase
|
||||
{
|
||||
public BehaviorView()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
<base:PageBase
|
||||
x:Class="TitleBar.MainView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:TitleBar"
|
||||
xmlns:base="using:TitleBar.Views.Base"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
DataContext="{Binding MainViewModel, Source={StaticResource Locator}}">
|
||||
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<StackPanel
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center">
|
||||
<Button Content="Use Code Behind"
|
||||
Click="CodeBehindClick"
|
||||
Margin="5"/>
|
||||
<Button Content="Use Behavior"
|
||||
Command="{Binding NavigateCommand}"
|
||||
Margin="5"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</base:PageBase>
|
|
@ -0,0 +1,33 @@
|
|||
namespace TitleBar
|
||||
{
|
||||
using Views.Base;
|
||||
using Windows.UI;
|
||||
using Windows.UI.ViewManagement;
|
||||
|
||||
public sealed partial class MainView : PageBase
|
||||
{
|
||||
public MainView()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private void CodeBehindClick(object sender, Windows.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
var applicationView = ApplicationView.GetForCurrentView();
|
||||
|
||||
// Title
|
||||
applicationView.Title = "Changed basic TitleBar Information";
|
||||
|
||||
// Basic TitleBar Properties
|
||||
var titleBar = applicationView.TitleBar;
|
||||
titleBar.BackgroundColor = (Color)App.Current.Resources["RedColor"];
|
||||
titleBar.ForegroundColor = (Color)App.Current.Resources["WhiteColor"];
|
||||
titleBar.ButtonBackgroundColor = (Color)App.Current.Resources["BlueColor"];
|
||||
titleBar.ButtonForegroundColor = (Color)App.Current.Resources["WhiteColor"];
|
||||
|
||||
// Extra
|
||||
titleBar.ButtonHoverBackgroundColor = Colors.Yellow;
|
||||
titleBar.ButtonPressedBackgroundColor = Colors.Orange;
|
||||
}
|
||||
}
|
||||
}
|
После Ширина: | Высота: | Размер: 801 B |
После Ширина: | Высота: | Размер: 329 B |
После Ширина: | Высота: | Размер: 2.1 KiB |
После Ширина: | Высота: | Размер: 429 B |
После Ширина: | Высота: | Размер: 2.1 KiB |
|
@ -0,0 +1,31 @@
|
|||
<!--
|
||||
This file contains Runtime Directives used by .NET Native. The defaults here are suitable for most
|
||||
developers. However, you can modify these parameters to modify the behavior of the .NET Native
|
||||
optimizer.
|
||||
|
||||
Runtime Directives are documented at http://go.microsoft.com/fwlink/?LinkID=391919
|
||||
|
||||
To fully enable reflection for App1.MyClass and all of its public/private members
|
||||
<Type Name="App1.MyClass" Dynamic="Required All"/>
|
||||
|
||||
To enable dynamic creation of the specific instantiation of AppClass<T> over System.Int32
|
||||
<TypeInstantiation Name="App1.AppClass" Arguments="System.Int32" Activate="Required Public" />
|
||||
|
||||
Using the Namespace directive to apply reflection policy to all the types in a particular namespace
|
||||
<Namespace Name="DataClasses.ViewModels" Seralize="All" />
|
||||
-->
|
||||
|
||||
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
|
||||
<Application>
|
||||
<!--
|
||||
An Assembly element with Name="*Application*" applies to all assemblies in
|
||||
the application package. The asterisks are not wildcards.
|
||||
-->
|
||||
<Assembly Name="*Application*" Dynamic="Required All" />
|
||||
|
||||
|
||||
<!-- Add your application specific runtime directives here. -->
|
||||
|
||||
|
||||
</Application>
|
||||
</Directives>
|