Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
541 views
in Technique[技术] by (71.8m points)

wpf - Why do I get FreezableCollection`1 is not a valid value in the XAML designer

I am trying to use Nish Nishant's classes to extend the system menu of a WPF window. Nish's project is in Code Project as An MVVM friendly approach to adding system menu entries in a WPF application

I have included Nish's source files in my project and defined some menu commands for the system menu.

This was easy and as far as I can tell it is working correctly. I am not getting a runtime error.

However, the XAML designer is showing me the error

'System.Windows.FreezableCollection`1[NS.MVVM.SystemMenuItem]' is not a valid value for property 'MenuItems'.

enter image description here

This error only appears after compiling the project. I do not get the error in Nish's sample project. I am using Visual Studio 2019 version 16.8.3. What might be causing this error message?

EDIT

I now know what is causing the error message, in the sense that I know what the difference is between my project and Nish's sample project.

Nish's project targets the x86 platform, whereas my project targeted Any CPU.

This is understandable, because the code uses Win32 API functions. I have changed the target platform for my project to x86 and the error has gone.

However, I still don't really understand why the error occurs and how it relates to the underlying issue of target platform.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...