Skip to content

Commit

Permalink
Merge pull request #1624 from Microsoft/nmetulev/sampleapp
Browse files Browse the repository at this point in the history
SampleApp updates and more
  • Loading branch information
nmetulev authored Nov 16, 2017
2 parents 881155d + 0e9a854 commit ae3771b
Show file tree
Hide file tree
Showing 99 changed files with 1,539 additions and 1,661 deletions.
693 changes: 370 additions & 323 deletions Microsoft.Toolkit.Uwp.SampleApp/App.xaml

Large diffs are not rendered by default.

Binary file modified Microsoft.Toolkit.Uwp.SampleApp/Assets/Helpers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
94 changes: 0 additions & 94 deletions Microsoft.Toolkit.Uwp.SampleApp/Common/AnimationHelper.cs

This file was deleted.

70 changes: 70 additions & 0 deletions Microsoft.Toolkit.Uwp.SampleApp/Common/XAMLHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************

using System.Reflection;
using Microsoft.Toolkit.Uwp.UI.Animations;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Media;

namespace Microsoft.Toolkit.Uwp.SampleApp
{
public static class XAMLHelper
{
public static Color GetBackground(FrameworkElement obj)
{
return (Color)obj.GetValue(BackgroundProperty);
}

public static void SetBackground(FrameworkElement obj, Color value)
{
obj.SetValue(BackgroundProperty, value);
}

// Using a DependencyProperty as the backing store for Background. This enables animation, styling, binding, etc...
public static readonly DependencyProperty BackgroundProperty =
DependencyProperty.RegisterAttached("Background", typeof(Color), typeof(XAMLHelper), new PropertyMetadata(Colors.White, OnBackgroundChanged));

private static void OnBackgroundChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (e.NewValue is Color color)
{
var type = d.GetType();
var backgroundProperty = type.GetProperty("Background");
if (backgroundProperty == null)
{
return;
}

var fullColor = Color.FromArgb(0xff, color.R, color.G, color.B);

if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.AcrylicBrush"))
{
AcrylicBrush myBrush = new AcrylicBrush
{
BackgroundSource = AcrylicBackgroundSource.Backdrop,
TintColor = fullColor,
FallbackColor = color,
TintOpacity = (double)color.A / 255d
};

backgroundProperty.SetValue(d, myBrush);
}
else
{
backgroundProperty.SetValue(d, new SolidColorBrush(color));
((FrameworkElement)d).Blur(3, duration: 0).Start();
}
}
}
}
}
Loading

0 comments on commit ae3771b

Please sign in to comment.