/ src / modules / cmdpal / Microsoft.CmdPal.UI / Controls / ScreenPreview.xaml.cs
ScreenPreview.xaml.cs
 1  // Copyright (c) Microsoft Corporation
 2  // The Microsoft Corporation licenses this file to you under the MIT license.
 3  // See the LICENSE file in the project root for more information.
 4  
 5  using Microsoft.CmdPal.UI.Helpers;
 6  using Microsoft.UI.Xaml;
 7  using Microsoft.UI.Xaml.Controls;
 8  using Microsoft.UI.Xaml.Markup;
 9  using Microsoft.UI.Xaml.Media;
10  
11  namespace Microsoft.CmdPal.UI.Controls;
12  
13  [ContentProperty(Name = nameof(PreviewContent))]
14  public sealed partial class ScreenPreview : UserControl
15  {
16      public static readonly DependencyProperty PreviewContentProperty =
17          DependencyProperty.Register(nameof(PreviewContent), typeof(object), typeof(ScreenPreview), new PropertyMetadata(null!))!;
18  
19      public object PreviewContent
20      {
21          get => GetValue(PreviewContentProperty)!;
22          set => SetValue(PreviewContentProperty, value);
23      }
24  
25      public ScreenPreview()
26      {
27          InitializeComponent();
28  
29          var wallpaperHelper = new WallpaperHelper();
30          WallpaperImage!.Source = wallpaperHelper.GetWallpaperImage()!;
31          ScreenBorder!.Background = new SolidColorBrush(wallpaperHelper.GetWallpaperColor());
32      }
33  }