Browse Source

Merge branch 'master' into realized-elements-cleanup-on-removal

pull/6847/head
Tako 5 years ago
committed by GitHub
parent
commit
c8e2ba618c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 26
      src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlDetailsViewModel.cs

26
src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlDetailsViewModel.cs

@ -24,7 +24,7 @@ namespace Avalonia.Diagnostics.ViewModels
private bool _showInactiveStyles; private bool _showInactiveStyles;
private string? _styleStatus; private string? _styleStatus;
private object _selectedEntity; private object _selectedEntity;
private readonly Stack<Tuple<string, object>> _selectedEntitiesStack = new Stack<Tuple<string, object>>(); private readonly Stack<(string Name, object Entry)> _selectedEntitiesStack = new();
private string _selectedEntityName; private string _selectedEntityName;
private string _selectedEntityType; private string _selectedEntityType;
@ -399,17 +399,25 @@ namespace Avalonia.Diagnostics.ViewModels
public void ApplySelectedProperty() public void ApplySelectedProperty()
{ {
if (SelectedProperty == null) return; var selectedProperty = SelectedProperty;
var selectedEntity = SelectedEntity;
var property = (_selectedEntity as IControl)?.GetValue(SelectedProperty.Key as AvaloniaProperty); var selectedEntityName = SelectedEntityName;
if (property == null) if (selectedProperty == null)
return;
object? property;
if (selectedProperty.Key is AvaloniaProperty avaloniaProperty)
{
property = (_selectedEntity as IControl)?.GetValue(avaloniaProperty);
}
else
{ {
property = _selectedEntity.GetType().GetProperty(SelectedProperty.Name)?.GetValue(_selectedEntity); property = _selectedEntity.GetType().GetProperty(selectedProperty.Name)?.GetValue(_selectedEntity);
} }
if (property == null) return; if (property == null) return;
_selectedEntitiesStack.Push(new Tuple<string, object>(SelectedEntityName, SelectedEntity)); _selectedEntitiesStack.Push((Name:selectedEntityName,Entry:selectedEntity));
NavigateToProperty(property, SelectedProperty.Name); NavigateToProperty(property, selectedProperty.Name);
} }
public void ApplyParentProperty() public void ApplyParentProperty()
@ -417,7 +425,7 @@ namespace Avalonia.Diagnostics.ViewModels
if (_selectedEntitiesStack.Any()) if (_selectedEntitiesStack.Any())
{ {
var property = _selectedEntitiesStack.Pop(); var property = _selectedEntitiesStack.Pop();
NavigateToProperty(property.Item2, property.Item1); NavigateToProperty(property.Entry, property.Name);
} }
} }

Loading…
Cancel
Save