

It’s more elegant and removes the need of code-behind. These attached properties allow to set the same properties we have seen before, but now directly in XAML: Private static void OnButtonBackgroundColorPropert圜hanged(DependencyObject d, Public static void SetButtonBackgroundColor(DependencyObject d, Color value)ĭ.SetValue(ButtonBackgroundColorProperty, value) Return (Color)d.GetValue(ButtonBackgroundColorProperty) Public static Color GetButtonBackgroundColor(DependencyObject d) New PropertyMetadata(null, OnButtonBackgroundColorPropert圜hanged)) Public static readonly DependencyProperty ButtonBackgroundColorProperty =ĭependencyProperty.RegisterAttached("ButtonBackgroundColor", typeof(Color),

Private static void OnButtonForegroundColorPropert圜hanged(DependencyObject d, Public static void SetButtonForegroundColor(DependencyObject d, Color value)ĭ.SetValue(ButtonForegroundColorProperty, value) Return (Color)d.GetValue(ButtonForegroundColorProperty) Public static Color GetButtonForegroundColor(DependencyObject d) New PropertyMetadata(null, OnButtonForegroundColorPropert圜hanged))

Public static readonly DependencyProperty ButtonForegroundColorProperty =ĭependencyProperty.RegisterAttached("ButtonForegroundColor", typeof(Color), Private static void OnBackgroundColorPropert圜hanged(DependencyObject d, Public static void SetBackgroundColor(DependencyObject d, Color value)ĭ.SetValue(BackgroundColorProperty, value)

Public static Color GetBackgroundColor(DependencyObject d) New PropertyMetadata(null, OnBackgroundColorPropert圜hanged)) Public static readonly DependencyProperty BackgroundColorProperty =ĭependencyProperty.RegisterAttached("BackgroundColor", typeof(Color), Var titleBar = ApplicationView.GetForCurrentView().TitleBar Private static void OnForegroundColorPropert圜hanged(DependencyObject d, Public static void SetForegroundColor(DependencyObject d, Color value)ĭ.SetValue(ForegroundColorProperty, value) Public static Color GetForegroundColor(DependencyObject d) New PropertyMetadata(null, OnForegroundColorPropert圜hanged)) Public static readonly DependencyProperty ForegroundColorProperty =ĭependencyProperty.RegisterAttached("ForegroundColor", typeof(Color), This solution works great, but we can improve it by defining the appropriate attached properties on the Page class, so that we can customize Title Bar colors via XAML: Windows 10 app Title Bar with custom chrome
