Skip to content

Commit ae3771b

Browse files
authored
Merge pull request #1624 from Microsoft/nmetulev/sampleapp
SampleApp updates and more
2 parents 881155d + 0e9a854 commit ae3771b

File tree

99 files changed

+1539
-1661
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+1539
-1661
lines changed

Microsoft.Toolkit.Uwp.SampleApp/App.xaml

Lines changed: 370 additions & 323 deletions
Large diffs are not rendered by default.
-4.93 KB
Loading
5.15 MB
Loading
-1.15 MB
Binary file not shown.

Microsoft.Toolkit.Uwp.SampleApp/Common/AnimationHelper.cs

Lines changed: 0 additions & 94 deletions
This file was deleted.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// ******************************************************************
2+
// Copyright (c) Microsoft. All rights reserved.
3+
// This code is licensed under the MIT License (MIT).
4+
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
5+
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
7+
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
8+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
9+
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
10+
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
11+
// ******************************************************************
12+
13+
using System.Reflection;
14+
using Microsoft.Toolkit.Uwp.UI.Animations;
15+
using Windows.UI;
16+
using Windows.UI.Xaml;
17+
using Windows.UI.Xaml.Media;
18+
19+
namespace Microsoft.Toolkit.Uwp.SampleApp
20+
{
21+
public static class XAMLHelper
22+
{
23+
public static Color GetBackground(FrameworkElement obj)
24+
{
25+
return (Color)obj.GetValue(BackgroundProperty);
26+
}
27+
28+
public static void SetBackground(FrameworkElement obj, Color value)
29+
{
30+
obj.SetValue(BackgroundProperty, value);
31+
}
32+
33+
// Using a DependencyProperty as the backing store for Background. This enables animation, styling, binding, etc...
34+
public static readonly DependencyProperty BackgroundProperty =
35+
DependencyProperty.RegisterAttached("Background", typeof(Color), typeof(XAMLHelper), new PropertyMetadata(Colors.White, OnBackgroundChanged));
36+
37+
private static void OnBackgroundChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
38+
{
39+
if (e.NewValue is Color color)
40+
{
41+
var type = d.GetType();
42+
var backgroundProperty = type.GetProperty("Background");
43+
if (backgroundProperty == null)
44+
{
45+
return;
46+
}
47+
48+
var fullColor = Color.FromArgb(0xff, color.R, color.G, color.B);
49+
50+
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.AcrylicBrush"))
51+
{
52+
AcrylicBrush myBrush = new AcrylicBrush
53+
{
54+
BackgroundSource = AcrylicBackgroundSource.Backdrop,
55+
TintColor = fullColor,
56+
FallbackColor = color,
57+
TintOpacity = (double)color.A / 255d
58+
};
59+
60+
backgroundProperty.SetValue(d, myBrush);
61+
}
62+
else
63+
{
64+
backgroundProperty.SetValue(d, new SolidColorBrush(color));
65+
((FrameworkElement)d).Blur(3, duration: 0).Start();
66+
}
67+
}
68+
}
69+
}
70+
}

0 commit comments

Comments
 (0)