diff --git a/samples/ControlCatalog/MainView.xaml b/samples/ControlCatalog/MainView.xaml index bdf5d15b6e..4a5f5bc96c 100644 --- a/samples/ControlCatalog/MainView.xaml +++ b/samples/ControlCatalog/MainView.xaml @@ -6,10 +6,230 @@ xmlns:pages="using:ControlCatalog.Pages" xmlns:viewModels="using:ControlCatalog.ViewModels" x:DataType="viewModels:MainWindowViewModel"> - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + None + BorderOnly + Full + + + + + FluentLight + FluentDark + SimpleLight + SimpleDark + + + + + None + Transparent + Blur + AcrylicBlur + Mica + + + + + LeftToRight + RightToLeft + + + + + + + + diff --git a/samples/ControlCatalog/MainView.xaml.cs b/samples/ControlCatalog/MainView.xaml.cs index ab36a74c12..15e666ae7b 100644 --- a/samples/ControlCatalog/MainView.xaml.cs +++ b/samples/ControlCatalog/MainView.xaml.cs @@ -17,6 +17,69 @@ namespace ControlCatalog { AvaloniaXamlLoader.Load(this); + var sideBar = this.Get("Sidebar"); + + if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime) + { + var tabItems = (sideBar.Items as IList); + tabItems?.Add(new TabItem() + { + Header = "Screens", + Content = new ScreenPage() + }); + } + + var themes = this.Get("Themes"); + themes.SelectedItem = App.CurrentTheme; + themes.SelectionChanged += (sender, e) => + { + if (themes.SelectedItem is CatalogTheme theme) + { + App.SetThemeVariant(theme); + } + }; + + var flowDirections = this.Get("FlowDirection"); + flowDirections.SelectionChanged += (sender, e) => + { + if (flowDirections.SelectedItem is FlowDirection flowDirection) + { + this.FlowDirection = flowDirection; + } + }; + + var decorations = this.Get("Decorations"); + decorations.SelectionChanged += (sender, e) => + { + if (VisualRoot is Window window + && decorations.SelectedItem is SystemDecorations systemDecorations) + { + window.SystemDecorations = systemDecorations; + } + }; + + var transparencyLevels = this.Get("TransparencyLevels"); + IDisposable? backgroundSetter = null, paneBackgroundSetter = null; + transparencyLevels.SelectionChanged += (sender, e) => + { + backgroundSetter?.Dispose(); + paneBackgroundSetter?.Dispose(); + if (transparencyLevels.SelectedItem is WindowTransparencyLevel selected + && selected != WindowTransparencyLevel.None) + { + var semiTransparentBrush = new ImmutableSolidColorBrush(Colors.Gray, 0.5); + backgroundSetter = sideBar.SetValue(BackgroundProperty, semiTransparentBrush, Avalonia.Data.BindingPriority.Style); + paneBackgroundSetter = sideBar.SetValue(SplitView.PaneBackgroundProperty, semiTransparentBrush, Avalonia.Data.BindingPriority.Style); + } + }; + } + + protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) + { + base.OnAttachedToVisualTree(e); + var decorations = this.Get("Decorations"); + if (VisualRoot is Window window) + decorations.SelectedIndex = (int)window.SystemDecorations; } } }