Skip to content

Commit a6273d1

Browse files
Fix #270: Wrong implementation of attached properties
1 parent 9e8ab4b commit a6273d1

File tree

1 file changed

+68
-6
lines changed

1 file changed

+68
-6
lines changed

ICSharpCode.AvalonEdit/Folding/FoldingMargin.cs

Lines changed: 68 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,25 @@ public class FoldingMargin : AbstractMargin
4747
/// FoldingMarkerBrush dependency property.
4848
/// </summary>
4949
public static readonly DependencyProperty FoldingMarkerBrushProperty =
50-
DependencyProperty.RegisterAttached("FoldingMarkerBrush", typeof(Brush), typeof(FoldingMargin),
50+
DependencyProperty.RegisterAttached(nameof(FoldingMarkerBrush), typeof(Brush), typeof(FoldingMargin),
5151
new FrameworkPropertyMetadata(Brushes.Gray, FrameworkPropertyMetadataOptions.Inherits, OnUpdateBrushes));
5252

53+
/// <summary>
54+
/// Gets the value of the <see cref="FoldingMarkerBrush"/> attached property for a specified <see cref="DependencyObject"/>.
55+
/// </summary>
56+
public static Brush GetFoldingMarkerBrush(DependencyObject obj)
57+
{
58+
return (Brush)obj.GetValue(FoldingMarkerBrushProperty);
59+
}
60+
61+
/// <summary>
62+
/// Sets the value of the <see cref="FoldingMarkerBrush"/> attached property for a specified <see cref="DependencyObject"/>.
63+
/// </summary>
64+
public static void SetFoldingMarkerBrush(DependencyObject obj, Brush value)
65+
{
66+
obj.SetValue(FoldingMarkerBrushProperty, value);
67+
}
68+
5369
/// <summary>
5470
/// Gets/sets the Brush used for displaying the lines of folding markers.
5571
/// </summary>
@@ -62,9 +78,25 @@ public Brush FoldingMarkerBrush {
6278
/// FoldingMarkerBackgroundBrush dependency property.
6379
/// </summary>
6480
public static readonly DependencyProperty FoldingMarkerBackgroundBrushProperty =
65-
DependencyProperty.RegisterAttached("FoldingMarkerBackgroundBrush", typeof(Brush), typeof(FoldingMargin),
81+
DependencyProperty.RegisterAttached(nameof(FoldingMarkerBackgroundBrush), typeof(Brush), typeof(FoldingMargin),
6682
new FrameworkPropertyMetadata(Brushes.White, FrameworkPropertyMetadataOptions.Inherits, OnUpdateBrushes));
6783

84+
/// <summary>
85+
/// Gets the value of the <see cref="FoldingMarkerBackgroundBrush"/> attached property for a specified <see cref="DependencyObject"/>.
86+
/// </summary>
87+
public static Brush GetFoldingMarkerBackgroundBrush(DependencyObject obj)
88+
{
89+
return (Brush)obj.GetValue(FoldingMarkerBackgroundBrushProperty);
90+
}
91+
92+
/// <summary>
93+
/// Sets the value of the <see cref="FoldingMarkerBackgroundBrush"/> attached property for a specified <see cref="DependencyObject"/>.
94+
/// </summary>
95+
public static void SetFoldingMarkerBackgroundBrush(DependencyObject obj, Brush value)
96+
{
97+
obj.SetValue(FoldingMarkerBackgroundBrushProperty, value);
98+
}
99+
68100
/// <summary>
69101
/// Gets/sets the Brush used for displaying the background of folding markers.
70102
/// </summary>
@@ -77,10 +109,25 @@ public Brush FoldingMarkerBackgroundBrush {
77109
/// SelectedFoldingMarkerBrush dependency property.
78110
/// </summary>
79111
public static readonly DependencyProperty SelectedFoldingMarkerBrushProperty =
80-
DependencyProperty.RegisterAttached("SelectedFoldingMarkerBrush",
81-
typeof(Brush), typeof(FoldingMargin),
112+
DependencyProperty.RegisterAttached(nameof(SelectedFoldingMarkerBrush), typeof(Brush), typeof(FoldingMargin),
82113
new FrameworkPropertyMetadata(Brushes.Black, FrameworkPropertyMetadataOptions.Inherits, OnUpdateBrushes));
83114

115+
/// <summary>
116+
/// Gets the value of the <see cref="SelectedFoldingMarkerBrush"/> attached property for a specified <see cref="DependencyObject"/>.
117+
/// </summary>
118+
public static Brush GetSelectedFoldingMarkerBrush(DependencyObject obj)
119+
{
120+
return (Brush)obj.GetValue(SelectedFoldingMarkerBrushProperty);
121+
}
122+
123+
/// <summary>
124+
/// Sets the value of the <see cref="SelectedFoldingMarkerBrush"/> attached property for a specified <see cref="DependencyObject"/>.
125+
/// </summary>
126+
public static void SetSelectedFoldingMarkerBrush(DependencyObject obj, Brush value)
127+
{
128+
obj.SetValue(SelectedFoldingMarkerBrushProperty, value);
129+
}
130+
84131
/// <summary>
85132
/// Gets/sets the Brush used for displaying the lines of selected folding markers.
86133
/// </summary>
@@ -93,10 +140,25 @@ public Brush SelectedFoldingMarkerBrush {
93140
/// SelectedFoldingMarkerBackgroundBrush dependency property.
94141
/// </summary>
95142
public static readonly DependencyProperty SelectedFoldingMarkerBackgroundBrushProperty =
96-
DependencyProperty.RegisterAttached("SelectedFoldingMarkerBackgroundBrush",
97-
typeof(Brush), typeof(FoldingMargin),
143+
DependencyProperty.RegisterAttached(nameof(SelectedFoldingMarkerBackgroundBrush), typeof(Brush), typeof(FoldingMargin),
98144
new FrameworkPropertyMetadata(Brushes.White, FrameworkPropertyMetadataOptions.Inherits, OnUpdateBrushes));
99145

146+
/// <summary>
147+
/// Gets the value of the <see cref="SelectedFoldingMarkerBackgroundBrush"/> attached property for a specified <see cref="DependencyObject"/>.
148+
/// </summary>
149+
public static Brush GetSelectedFoldingMarkerBackgroundBrush(DependencyObject obj)
150+
{
151+
return (Brush)obj.GetValue(SelectedFoldingMarkerBackgroundBrushProperty);
152+
}
153+
154+
/// <summary>
155+
/// Sets the value of the <see cref="SelectedFoldingMarkerBackgroundBrush"/> attached property for a specified <see cref="DependencyObject"/>.
156+
/// </summary>
157+
public static void SetSelectedFoldingMarkerBackgroundBrush(DependencyObject obj, Brush value)
158+
{
159+
obj.SetValue(SelectedFoldingMarkerBackgroundBrushProperty, value);
160+
}
161+
100162
/// <summary>
101163
/// Gets/sets the Brush used for displaying the background of selected folding markers.
102164
/// </summary>

0 commit comments

Comments
 (0)