File tree 2 files changed +9
-16
lines changed
Avalonia.Diagnostics/Diagnostics/ViewModels
2 files changed +9
-16
lines changed Original file line number Diff line number Diff line change @@ -180,12 +180,6 @@ public string? Name
180
180
/// Classes can be used to apply user-defined styling to styled elements, or to allow styled elements
181
181
/// that share a common purpose to be easily selected.
182
182
/// </para>
183
- /// <para>
184
- /// Even though this property can be set, the setter is only intended for use in object
185
- /// initializers. Assigning to this property does not change the underlying collection,
186
- /// it simply clears the existing collection and adds the contents of the assigned
187
- /// collection.
188
- /// </para>
189
183
/// </remarks>
190
184
public Classes Classes => _classes ??= new ( ) ;
191
185
Original file line number Diff line number Diff line change @@ -15,26 +15,25 @@ internal abstract class TreeNode : ViewModelBase, IDisposable
15
15
private string _classes ;
16
16
private bool _isExpanded ;
17
17
18
- protected TreeNode ( AvaloniaObject avaloniaObject , TreeNode ? parent , string ? customName = null )
18
+ protected TreeNode ( AvaloniaObject avaloniaObject , TreeNode ? parent , string ? customTypeName = null )
19
19
{
20
20
_classes = string . Empty ;
21
21
Parent = parent ;
22
- var visual = avaloniaObject ;
23
- Type = customName ?? avaloniaObject . GetType ( ) . Name ;
24
- Visual = visual ! ;
22
+ Type = customTypeName ?? avaloniaObject . GetType ( ) . Name ;
23
+ Visual = avaloniaObject ;
25
24
FontWeight = IsRoot ? FontWeight . Bold : FontWeight . Normal ;
26
25
27
- if ( visual is Control control )
28
- {
29
- ElementName = control . Name ;
26
+ ElementName = ( avaloniaObject as INamed ) ? . Name ;
30
27
31
- _classesSubscription = ( ( IObservable < object ? > ) control . Classes . GetWeakCollectionChangedObservable ( ) )
28
+ if ( avaloniaObject is StyledElement { Classes : { } classes } )
29
+ {
30
+ _classesSubscription = ( ( IObservable < object ? > ) classes . GetWeakCollectionChangedObservable ( ) )
32
31
. StartWith ( null )
33
32
. Subscribe ( _ =>
34
33
{
35
- if ( control . Classes . Count > 0 )
34
+ if ( classes . Count > 0 )
36
35
{
37
- Classes = "(" + string . Join ( " " , control . Classes ) + " )";
36
+ Classes = $ "( { string . Join ( " " , classes ) } )";
38
37
}
39
38
else
40
39
{
You can’t perform that action at this time.
0 commit comments