Kaynağa Gözat

Move transparency to window customizations page.

Dan Walmsley 5 yıl önce
ebeveyn
işleme
d4fa9ad406

+ 0 - 7
samples/ControlCatalog/MainView.xaml.cs

@@ -58,13 +58,6 @@ namespace ControlCatalog
                 if (VisualRoot is Window window)
                     window.SystemDecorations = (SystemDecorations)decorations.SelectedIndex;
             };
-
-            var transparencyLevels = this.Find<ComboBox>("TransparencyLevels");
-            transparencyLevels.SelectionChanged += (sender, e) =>
-            {
-                if (VisualRoot is Window window)
-                    window.TransparencyLevelHint = (WindowTransparencyLevel)transparencyLevels.SelectedIndex;
-            };
         }
 
         protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)

+ 1 - 0
samples/ControlCatalog/MainWindow.xaml

@@ -10,6 +10,7 @@
         ExtendClientAreaToDecorationsHint="{Binding ExtendClientAreaEnabled}"
         ExtendClientAreaChromeHints="{Binding ChromeHints}"
         ExtendClientAreaTitleBarHeightHint="{Binding TitleBarHeight}"
+        TransparencyLevelHint="{Binding TransparencyLevel}"
         x:Name="MainWindow"
         x:Class="ControlCatalog.MainWindow" WindowState="{Binding WindowState, Mode=TwoWay}" Background="{x:Null}">
   <NativeMenu.Menu>

+ 5 - 0
samples/ControlCatalog/Pages/WindowCustomizationsPage.xaml

@@ -9,5 +9,10 @@
     <CheckBox Content="Titlebar" IsChecked="{Binding SystemTitleBarEnabled}" />
     <CheckBox Content="System Chrome Buttons" IsChecked="{Binding SystemChromeButtonsEnabled}" />
     <Slider Minimum="-1" Maximum="200" Value="{Binding TitleBarHeight}" />
+    <ComboBox x:Name="TransparencyLevels" SelectedIndex="{Binding TransparencyLevel}">
+      <ComboBoxItem>None</ComboBoxItem>
+      <ComboBoxItem>Transparent</ComboBoxItem>
+      <ComboBoxItem>Blur</ComboBoxItem>
+    </ComboBox>
   </StackPanel>
 </UserControl>

+ 12 - 0
samples/ControlCatalog/ViewModels/MainWindowViewModel.cs

@@ -80,6 +80,18 @@ namespace ControlCatalog.ViewModels
                         ChromeHints |= ExtendClientAreaChromeHints.SystemTitleBar;
                     }
                 });
+
+            SystemTitleBarEnabled = true;
+            SystemChromeButtonsEnabled = true;
+            TitleBarHeight = -1;
+        }
+
+        private int _transparencyLevel;
+
+        public int TransparencyLevel
+        {
+            get { return _transparencyLevel; }
+            set { this.RaiseAndSetIfChanged(ref _transparencyLevel, value); }
         }
 
         private ExtendClientAreaChromeHints _chromeHints;