我正在学习来自常规 WPF 的 MVVM 模式。我的大部分工作都是基于界面的。我喜欢 Visual Studio 中的设计视图和混合,因此我可以根据自己的喜好快速定位控件。我对学习 MVVM 很感兴趣,但是当我将视图 UserControl 绑定到 MainWindow 时,我看不到设计。我已经仔细研究了设置,但找不到可以修复它的选项。有没有办法在设计视图中查看 UserControl?
任何帮助是极大的赞赏!
我正在学习来自常规 WPF 的 MVVM 模式。我的大部分工作都是基于界面的。我喜欢 Visual Studio 中的设计视图和混合,因此我可以根据自己的喜好快速定位控件。我对学习 MVVM 很感兴趣,但是当我将视图 UserControl 绑定到 MainWindow 时,我看不到设计。我已经仔细研究了设置,但找不到可以修复它的选项。有没有办法在设计视图中查看 UserControl?
任何帮助是极大的赞赏!
A usercontrol just works in design view.
You double click the XAML file and it opens in the designer.
If it's entirely constructed from templating which is reliant on viewmodel data then you'd need to provide a viewmodel with that data somehow OR a designer viewmodel.
There are various ways to approach that.
Since you've shown us absolutely no code, it's guess work as to what you've done or what the best route would be to take from there to wherever you want to head.
"quickly position controls to my liking"
That sounds like you're maybe dragging in the designer.
When working with the designer, imo it is a mistake to drag things about on the design surface. You very quickly get something that will only work on your display settings and is a nightmare to troubleshoot layout issues. Instead, edit the XAML and see what you get in the designer.