wpfui icon indicating copy to clipboard operation
wpfui copied to clipboard

Cannot access Freezable 'System.Windows.Media.SolidColorBrush' across threads

Open ghost1372 opened this issue 1 year ago • 1 comments

Describe the bug

System.Windows.Markup.XamlParseException: 'Initialization of 'System.Windows.Controls.Primitives.StatusBar' threw an exception.' InvalidOperationException: Cannot access Freezable 'System.Windows.Media.SolidColorBrush' across threads because it cannot be frozen.

To Reproduce

use wpfui in a app which does not have any app.xaml, Add Resources in MainWindow:

Application.Current.Resources.MergedDictionaries.Add(new ThemesDictionary { Theme = Wpf.Ui.Appearance.ApplicationTheme.Dark });
Application.Current.Resources.MergedDictionaries.Add(new ControlsDictionary());

Try to Close Window and we get exception

Expected behavior

app should be closed without error

Screenshots

No response

OS version

Windows 11-22631

.NET version

472

WPF-UI NuGet version

latest-preview

Additional context

No response

ghost1372 avatar Nov 27 '23 12:11 ghost1372

This line should be DynamicResource I guess.

https://github.com/lepoco/wpfui/blob/8afb0d93bfa2dfde04672707f2563ad1fd981658/src/Wpf.Ui/Resources/Theme/Dark.xaml#L321

https://github.com/lepoco/wpfui/blob/8afb0d93bfa2dfde04672707f2563ad1fd981658/src/Wpf.Ui/Resources/Theme/Light.xaml#L321

ricaun avatar Nov 27 '23 18:11 ricaun