Open bujma opened 2 weeks ago
Thank you for providing the complete sample code; I think this will be helpful in fixing this bug.
I observed that you were utilizing the ResourceDictionary
within the MainWindow
; however, when I configure the ResourceDictionary
in the App.xaml
, this exception does not occur.
Is it unsupported in WPF to put style resources into Window
? Or is putting the resources into App.xaml
the only way to have it working?
The situation is: all our WPF windows/user controls are in libraries. The libraries are used from win32 (non .NET) code => there is no Application
object created. I know, I can create own one in the library and merge the WPF-UI resources into it - I already do it with our current WPF styles that we want to replace with WPF-UI. But if I do it this way, all windows are affected by these styles at once and we want to restyle them one by one and to not wait with the release until all of them are restyled - it's OK for us to have some with our old style and some with WPF-UI's (our one is close to WPF-UI, so not a big "disharmony").
I already have bad experience with this "general styles" approach: when an application loads our library with its styles automatically merged into Application
's resources, all styles of the application itself and of other libraries are affected. Therefore I decided to put WPF-UI resources directly to windows/user controls that are being restyled.
Is there any better solution I am not aware of?
Thanks much for your help.
Is it unsupported in WPF to put style resources into
Window
? Or is putting the resources intoApp.xaml
the only way to have it working?The situation is: all our WPF windows/user controls are in libraries. The libraries are used from win32 (non .NET) code => there is no
Application
object created. I know, I can create own one in the library and merge the WPF-UI resources into it - I already do it with our current WPF styles that we want to replace with WPF-UI. But if I do it this way, all windows are affected by these styles at once and we want to restyle them one by one and to not wait with the release until all of them are restyled - it's OK for us to have some with our old style and some with WPF-UI's (our one is close to WPF-UI, so not a big "disharmony"). I already have bad experience with this "general styles" approach: when an application loads our library with its styles automatically merged intoApplication
's resources, all styles of the application itself and of other libraries are affected. Therefore I decided to put WPF-UI resources directly to windows/user controls that are being restyled.Is there any better solution I am not aware of?
Thanks much for your help.
Sorry, I'm not quite knowledgeable about this aspect either.
Thanks for your response. I was trying the same with some other styles placed directly in Window's resources - as is perfectly common in WPF - and everything worked. How can this unexpected behaviour of WPF-UI resources be fixed?
Thanks for the time of you all.
Describe the bug
System.ArgumentNullException: 'Value cannot be null. Parameter name: defaultDestinationValue' when removing items of
ObserableCollection<Model>
bound from ViewModel class toItemsControl
inWindow
withItemTemplate
templated withCardExpander
after expanding anyCardExpander
.To Reproduce
Situation:
MainWindow
(pureWindow
descendant, noFluentWindow
) withResources
<ui:ThemesDictionary Theme="Light" />
and<ui:ControlsDictionary />
.MainWindow
with simpleViewModel
class asDataContext
.ViewModel
class withObservableCollection<Model> Items
property bound toItemsControl
havingItemTemplate
asCardExpander
.Steps:
Items
with someModel
items (button [Reload Items] callingItems = new ObservableCollection<Model>(list)
).CardExpander
.ObservableCollection
toItems
property (buttons [Delete], [Remove All Items] or [Reload Items] callingItems.Remove(item)
,Items.Clear()
or code from step 1).=> exception will be thrown
Description:
ErrorProof.zip
Expected behavior
No exception thrown. Removing items from
ObservableCollection
or assigning new instance should have no such impact.Screenshots
No response
OS version
Windows 10 Pro 22H2 19045.4529
.NET version
4.7.2
WPF-UI NuGet version
3.0.4
Additional context
No response