简体   繁体   中英

Issues Debugging MVVM Bindings in Visual Studio 2010?

I'm developing an application in Visual Studio using MVVM Light and Ninject. Unfortunately, when I try to debug this application and there's a problem in one of my ViewModels, instead of actually debugging the code, I get something like this:

调试映像示例

This is rather useless and impossible to debug. Now, if I know where the error is or have an idea, I can insert breakpoints there in the code and Visual Studio will show the correct info, but I don't always know where the error is. I can't just breakpoint every line of code in the application. Is there a way to force Visual Studio to look past the UI and debug the actual code?

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.

I am not able to view the error please make it large or type it in text format. This is from my page.

<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">

Match this may be it can help Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM