Closed robloo closed 11 months ago
@maxkatz6 @timunie Should I close this?
@robloo I have mixed feelings here and let the team decide. Thx for remembering me anyways
(Try)FindResource works with both Control.Resources and Control.Styles here. I still don't understand where is the issue.
It works specifically due to: https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Controls/Application.cs#L212-L217 https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Base/Styling/Styles.cs#L118-L135 https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Base/StyledElement.cs#L453-L458
I assume original confusion goes from the App.Resources["Name"]
usage, which will ignore styles. Which is exactly the confusing in https://github.com/AvaloniaUI/Avalonia/issues/6021. But as I said, there is no need to yet another "find resource" method.
@maxkatz6 I wouldn't say there is a confusion here at this point. It simply does not work on my end in a real app and the helper method discussed is required. I checked it again to confirm and this isn't just me either: others using FluentAvalonia are seeing it too. That likely means there is a bug some place. It's not worth our time to discuss this further for documentation so I'll close this. The work-around will remain in my code.
Separately, it would be good to align the indexer lookup implementation to match WPF.
@timunie I update the section you were working on to include a bit more info for those coming from other XAML UI frameworks. Accessing resources from code is a little tricky in Avalonia (and honestly it needs to be better). Discussion was here: