From a6273d114953dd72bebecad2a9df2c0022138039 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Mon, 15 Mar 2021 17:58:19 +0100 Subject: [PATCH] Fix #270: Wrong implementation of attached properties --- .../Folding/FoldingMargin.cs | 74 +++++++++++++++++-- 1 file changed, 68 insertions(+), 6 deletions(-) diff --git a/ICSharpCode.AvalonEdit/Folding/FoldingMargin.cs b/ICSharpCode.AvalonEdit/Folding/FoldingMargin.cs index 77f33d4..52a6ed8 100644 --- a/ICSharpCode.AvalonEdit/Folding/FoldingMargin.cs +++ b/ICSharpCode.AvalonEdit/Folding/FoldingMargin.cs @@ -47,9 +47,25 @@ namespace ICSharpCode.AvalonEdit.Folding /// FoldingMarkerBrush dependency property. /// public static readonly DependencyProperty FoldingMarkerBrushProperty = - DependencyProperty.RegisterAttached("FoldingMarkerBrush", typeof(Brush), typeof(FoldingMargin), + DependencyProperty.RegisterAttached(nameof(FoldingMarkerBrush), typeof(Brush), typeof(FoldingMargin), new FrameworkPropertyMetadata(Brushes.Gray, FrameworkPropertyMetadataOptions.Inherits, OnUpdateBrushes)); + /// + /// Gets the value of the attached property for a specified . + /// + public static Brush GetFoldingMarkerBrush(DependencyObject obj) + { + return (Brush)obj.GetValue(FoldingMarkerBrushProperty); + } + + /// + /// Sets the value of the attached property for a specified . + /// + public static void SetFoldingMarkerBrush(DependencyObject obj, Brush value) + { + obj.SetValue(FoldingMarkerBrushProperty, value); + } + /// /// Gets/sets the Brush used for displaying the lines of folding markers. /// @@ -62,9 +78,25 @@ namespace ICSharpCode.AvalonEdit.Folding /// FoldingMarkerBackgroundBrush dependency property. /// public static readonly DependencyProperty FoldingMarkerBackgroundBrushProperty = - DependencyProperty.RegisterAttached("FoldingMarkerBackgroundBrush", typeof(Brush), typeof(FoldingMargin), + DependencyProperty.RegisterAttached(nameof(FoldingMarkerBackgroundBrush), typeof(Brush), typeof(FoldingMargin), new FrameworkPropertyMetadata(Brushes.White, FrameworkPropertyMetadataOptions.Inherits, OnUpdateBrushes)); + /// + /// Gets the value of the attached property for a specified . + /// + public static Brush GetFoldingMarkerBackgroundBrush(DependencyObject obj) + { + return (Brush)obj.GetValue(FoldingMarkerBackgroundBrushProperty); + } + + /// + /// Sets the value of the attached property for a specified . + /// + public static void SetFoldingMarkerBackgroundBrush(DependencyObject obj, Brush value) + { + obj.SetValue(FoldingMarkerBackgroundBrushProperty, value); + } + /// /// Gets/sets the Brush used for displaying the background of folding markers. /// @@ -77,10 +109,25 @@ namespace ICSharpCode.AvalonEdit.Folding /// SelectedFoldingMarkerBrush dependency property. /// public static readonly DependencyProperty SelectedFoldingMarkerBrushProperty = - DependencyProperty.RegisterAttached("SelectedFoldingMarkerBrush", - typeof(Brush), typeof(FoldingMargin), + DependencyProperty.RegisterAttached(nameof(SelectedFoldingMarkerBrush), typeof(Brush), typeof(FoldingMargin), new FrameworkPropertyMetadata(Brushes.Black, FrameworkPropertyMetadataOptions.Inherits, OnUpdateBrushes)); + /// + /// Gets the value of the attached property for a specified . + /// + public static Brush GetSelectedFoldingMarkerBrush(DependencyObject obj) + { + return (Brush)obj.GetValue(SelectedFoldingMarkerBrushProperty); + } + + /// + /// Sets the value of the attached property for a specified . + /// + public static void SetSelectedFoldingMarkerBrush(DependencyObject obj, Brush value) + { + obj.SetValue(SelectedFoldingMarkerBrushProperty, value); + } + /// /// Gets/sets the Brush used for displaying the lines of selected folding markers. /// @@ -93,10 +140,25 @@ namespace ICSharpCode.AvalonEdit.Folding /// SelectedFoldingMarkerBackgroundBrush dependency property. /// public static readonly DependencyProperty SelectedFoldingMarkerBackgroundBrushProperty = - DependencyProperty.RegisterAttached("SelectedFoldingMarkerBackgroundBrush", - typeof(Brush), typeof(FoldingMargin), + DependencyProperty.RegisterAttached(nameof(SelectedFoldingMarkerBackgroundBrush), typeof(Brush), typeof(FoldingMargin), new FrameworkPropertyMetadata(Brushes.White, FrameworkPropertyMetadataOptions.Inherits, OnUpdateBrushes)); + /// + /// Gets the value of the attached property for a specified . + /// + public static Brush GetSelectedFoldingMarkerBackgroundBrush(DependencyObject obj) + { + return (Brush)obj.GetValue(SelectedFoldingMarkerBackgroundBrushProperty); + } + + /// + /// Sets the value of the attached property for a specified . + /// + public static void SetSelectedFoldingMarkerBackgroundBrush(DependencyObject obj, Brush value) + { + obj.SetValue(SelectedFoldingMarkerBackgroundBrushProperty, value); + } + /// /// Gets/sets the Brush used for displaying the background of selected folding markers. ///