New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to cast object of type 'Mocks.MaterialDesignDemo_ColorToolViewModel_2_47133230' to type 'System.Windows.Media.SolidColorBrush'. #1411
Comments
|
That's only a design time error. Sadly those are very common for bigger projects and often hard to prevent. The reason for such errors is e.g. that some services/classes can't be instantiated in design time or just some things not working in design time or no design time datacontext is set... |
I got it ,Thank you very much~ |
|
If you want to, then you can replace d:DataContext="{d:DesignInstance Type=local:ColorToolViewModel}"with d:DataContext="{d:DesignInstance Type=local:ColorToolViewModel, IsDesignTimeCreatable=True}"The design context doesn't fit well here. It'll load, but have other issues instead |
Ok,I tried the method you said, it can be displayed normally, thank you!! |
|
Thanks @jespersh. If someone wants to submit a PR with the design time DataContext change as mentioned above I would be happy to accept it. |
|
@Keboo it will make it load, but I don't think it is the right answer either. Instead a dedicated designmodel would be the better answer. |
|
@jespersh yea I agree, that would be a better solution. |


Hi
After downloading the source code, I installed .netcore3.0 and .net 4.7.2. After running with vs2019, the demo can run normally but the WPF view page is prompted to report an error. The screenshot is as follows. What is the reason? Is there a library missing?
Error message
Unable to cast object of type 'Mocks.MaterialDesignDemo_ColorToolViewModel_2_47133230' to type 'System.Windows.Media.SolidColorBrush'. MaterialDesignDemo ColorTool.xaml 1
The text was updated successfully, but these errors were encountered: