Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upUnable to cast object of type 'Mocks.MaterialDesignDemo_ColorToolViewModel_2_47133230' to type 'System.Windows.Media.SolidColorBrush'. #1411
Comments
This comment has been minimized.
This comment has been minimized.
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... |
This comment has been minimized.
This comment has been minimized.
I got it ,Thank you very much~ |
This comment has been minimized.
This comment has been minimized.
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 |
This comment has been minimized.
This comment has been minimized.
Ok,I tried the method you said, it can be displayed normally, thank you!! |
This comment has been minimized.
This comment has been minimized.
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. |
This comment has been minimized.
This comment has been minimized.
@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. |
This comment has been minimized.
This comment has been minimized.
@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