0

我正在使用 MVVM Light 和 Ninject 在 Visual Studio 中开发应用程序。不幸的是,当我尝试调试此应用程序并且我的一个 ViewModel 中存在问题时,我没有实际调试代码,而是得到如下信息:

示例调试图像

这是相当无用且无法调试的。现在,如果我知道错误在哪里或有想法,我可以在代码中插入断点,Visual Studio 将显示正确的信息,但我并不总是知道错误在哪里。我不能只对应用程序中的每一行代码都设置断点。有没有办法强制 Visual Studio 查看 UI 并调试实际代码?

4

2 回答 2

1

There is no need to set the owner of the application main window.

The correct way to set the owner of a window in XAML is as follows

<object>
  <object.Owner>
    <Window .../>
  </object.Owner>
</object>

alternatively you can set it from code behind like this

// Create a window and make this window its owner
Window ownedWindow = new Window();
ownedWindow.Owner = this;
ownedWindow.Show();

The way you have done WPF tries to convert the string "Auto_Calibrator_v0._05.MainWindow" to window object which is not possible unless you have a type converter.

于 2013-08-19T21:24:24.183 回答
0

我无法查看错误,请将其放大或以文本格式输入。这是来自我的页面。

<UserControl x:Class="Retail.View.Settings.ShopSetting"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d"      `      
             DataContext="{Binding Source={StaticResource Locator}, Path=ShopSettingVM}"
             xmlns:ctrl="clr-namespace:RetailPOS.View.Usercontrols.Settings"
             xmlns:Utility="clr-namespace:RetailPOS.Utility" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
             xmlns:Toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit">

匹配这个可能会有所帮助谢谢

于 2013-09-15T06:11:39.030 回答