PrismLibrary / Prism

Prism is a framework for building loosely coupled, maintainable, and testable XAML applications in WPF, Xamarin Forms, and Uno / Win UI Applications..
Other
6.35k stars 1.64k forks source link

[BUG] <title> #3277

Open BruceLeeCorner opened 22 hours ago

BruceLeeCorner commented 22 hours ago

Description

Hi, dear guys,

I try to do this : _eventAggregator.GetEvent<AppConfigChangedEvent>().Publish(); But appConfigSource.GetConfig(); doesn't execute if my ViewModel like the following :

public MainWindowViewModel( IEventAggregator eventAggregator, AppConfigSource appConfigSource)
{
    _eventAggregator = eventAggregator;
    _appConfigSource = appConfigSource;
    _eventAggregator.GetEvent<AppConfigChangedEvent>().Subscribe(() =>
    {
           appConfigSource.GetConfig();
    });
}

modify little to like this, It can work.

public MainWindowViewModel( IEventAggregator eventAggregator, AppConfigSource appConfigSource)
{
    _eventAggregator = eventAggregator;
    _appConfigSource = appConfigSource;
    _eventAggregator.GetEvent<AppConfigChangedEvent>().Subscribe(() =>
    {
           _appConfigSource.GetConfig();
    });
}

Lambda Can't use method parameter appConfigSource, and have to use field _appConfigSource.

I try debug prism source code ,find this :

image

is this a bug, please ? thank you.

Steps to Reproduce

none

Platform with bug

WPF

Affected platforms

Windows

Did you find any workaround?

No response

Relevant log output

No response

BruceLeeCorner commented 22 hours ago

I use Prism.DryIoc 8.1.97