wpfui icon indicating copy to clipboard operation
wpfui copied to clipboard

Changing SnackbarService presenter has no effect

Open aienabled opened this issue 6 months ago • 0 comments
trafficstars

Describe the bug

Good day, as I've noticed calling SnackbarService.SetSnackbarPresenter with intention to change the snackbar presenter to another control has no effect if the SnackbarService was used at least once (the Show method was called) because it's storing the old host value in its private field (this._snackbar).

https://github.com/lepoco/wpfui/blob/776d9c79391a3d5d4505561dd38d5463148c55b3/src/Wpf.Ui/SnackbarService.cs#L25

My suggestion is to reset the this._snackbar when SetSnackbarPresenter is called, but I have no knowledge whether the already existing instance should be disposed in some specific way.

To Reproduce

  1. Use SnackbarService.SetSnackbarPresenter
  2. Call SnackbarService.Show
  3. Use SnackbarService.SetSnackbarPresenter again but provide another snackbar presenter
  4. Call SnackbarService.Show, observe that the old snackbar presenter is used

Expected behavior

SnackbarService must use the new presenter instead of the old one.

Screenshots

No response

OS version

Windows 11

.NET version

.NET Framework 4.8

WPF-UI NuGet version

4.0.2

Additional context

No response

aienabled avatar Apr 24 '25 22:04 aienabled