1
- using ICSharpCode . AvalonEdit ;
1
+ // Licensed to the .NET Foundation under one or more agreements.
2
+ // The .NET Foundation licenses this file to you under the MIT license.
3
+ // See the LICENSE file in the project root for more information.
4
+
5
+ using ICSharpCode . AvalonEdit ;
2
6
using MahApps . Demo . Core ;
3
- using System ;
4
- using System . Collections . Generic ;
5
7
using System . Collections . ObjectModel ;
6
8
using System . Diagnostics ;
7
- using System . Linq ;
8
- using System . Text ;
9
- using System . Threading . Tasks ;
10
9
using System . Windows ;
11
10
using System . Windows . Controls ;
12
11
@@ -22,12 +21,10 @@ public class DemoView : HeaderedContentControl
22
21
23
22
/// <summary>Identifies the <see cref="HyperlinkOnlineDocs"/> dependency property.</summary>
24
23
public static readonly DependencyProperty HyperlinkOnlineDocsProperty = DependencyProperty . Register ( nameof ( HyperlinkOnlineDocs ) , typeof ( string ) , typeof ( DemoView ) , new PropertyMetadata ( null ) ) ;
25
-
26
-
27
24
28
25
public DemoView ( )
29
26
{
30
- DemoProperties . CollectionChanged += DemoProperties_CollectionChanged ;
27
+ this . DemoProperties . CollectionChanged += this . DemoProperties_CollectionChanged ;
31
28
}
32
29
33
30
public ObservableCollection < DemoViewProperty > DemoProperties { get ; } = new ObservableCollection < DemoViewProperty > ( ) ;
@@ -38,43 +35,42 @@ private void DemoProperties_CollectionChanged(object sender, System.Collections.
38
35
{
39
36
foreach ( DemoViewProperty item in e . NewItems )
40
37
{
41
- item . PropertyChanged += DemoProperties_ItemPropertyChanged ;
38
+ item . PropertyChanged += this . DemoProperties_ItemPropertyChanged ;
42
39
}
43
40
}
41
+
44
42
if ( e . OldItems != null )
45
43
{
46
44
foreach ( DemoViewProperty item in e . OldItems )
47
45
{
48
- item . PropertyChanged -= DemoProperties_ItemPropertyChanged ;
46
+ item . PropertyChanged -= this . DemoProperties_ItemPropertyChanged ;
49
47
}
50
48
}
51
49
}
52
50
53
51
private void DemoProperties_ItemPropertyChanged ( object sender , System . ComponentModel . PropertyChangedEventArgs e )
54
52
{
55
- SetExampleXaml ( ) ;
53
+ this . SetExampleXaml ( ) ;
56
54
}
57
55
58
-
59
-
60
56
public string ExampleXaml
61
57
{
62
- get { return ( string ) GetValue ( ExampleXamlProperty ) ; }
63
- set { SetValue ( ExampleXamlProperty , value ) ; }
58
+ get => ( string ) this . GetValue ( ExampleXamlProperty ) ;
59
+ set => this . SetValue ( ExampleXamlProperty , value ) ;
64
60
}
65
61
66
62
private void SetExampleXaml ( )
67
63
{
68
- if ( PART_AvalonEdit != null )
64
+ if ( this . PART_AvalonEdit != null )
69
65
{
70
- var exampleText = ExampleXaml ;
66
+ var exampleText = this . ExampleXaml ;
71
67
72
- foreach ( var item in DemoProperties )
68
+ foreach ( var item in this . DemoProperties )
73
69
{
74
70
exampleText = exampleText . Replace ( $ "[{ item . PropertyName } ]", item . GetExampleXamlContent ( ) ) ;
75
71
}
76
72
77
- PART_AvalonEdit . Text = exampleText ;
73
+ this . PART_AvalonEdit . Text = exampleText ;
78
74
}
79
75
}
80
76
@@ -88,8 +84,8 @@ private static void OnExampleXamlChanged(DependencyObject d, DependencyPropertyC
88
84
89
85
public string HyperlinkOnlineDocs
90
86
{
91
- get { return ( string ) GetValue ( HyperlinkOnlineDocsProperty ) ; }
92
- set { SetValue ( HyperlinkOnlineDocsProperty , value ) ; }
87
+ get => ( string ) this . GetValue ( HyperlinkOnlineDocsProperty ) ;
88
+ set => this . SetValue ( HyperlinkOnlineDocsProperty , value ) ;
93
89
}
94
90
95
91
public SimpleCommand NavigateToOnlineDocs { get ; } = new SimpleCommand (
@@ -100,9 +96,8 @@ public override void OnApplyTemplate()
100
96
{
101
97
base . OnApplyTemplate ( ) ;
102
98
103
- PART_AvalonEdit = GetTemplateChild ( nameof ( PART_AvalonEdit ) ) as TextEditor ;
104
- SetExampleXaml ( ) ;
99
+ this . PART_AvalonEdit = this . GetTemplateChild ( nameof ( this . PART_AvalonEdit ) ) as TextEditor ;
100
+ this . SetExampleXaml ( ) ;
105
101
}
106
-
107
102
}
108
- }
103
+ }
0 commit comments