2016-05-24 25 views
0

MVVMLightを使用してDataTableをDataGridにバインドしようとしています。私はデータを表示することができますが、グリッドをスクロールしたりセルを編集しようとすると、いくつかのバインディングエラーが表示されます。これはパフォーマンスの問題を引き起こしているようですが、なぜそれらが出現するのか不思議です。以下のコードでは、1つのセルがいっぱいになり、新しいセルを編集するとエラーが発生します。私はこれを試したことがある他の時間、私は大きなDataTablesを作成し、DataGridをスクロールするときに同じエラーが発生しました。私はDataGridのプロパティで遊んでみましたが、何もエラーを取り除くことはできません。バインディングがMVVMLightで設定された後のWPF Datagridバインディングエラー

編集:私はDefaultViewを使ってみましたが、問題を解決していないようです。ここで

は私のVMコードです:

using GalaSoft.MvvmLight; 
using System.Collections.ObjectModel; 
using System.Data; 
using System.Windows.Controls; 
using System.Windows.Data; 

namespace DatagridTest1.ViewModel 
{ 
    public class MainViewModel : ViewModelBase 
    { 
    public DataTable Data2 
     { 
      get 
      { 
       return data2; 
      } 
      set 
      { 
       Set(() => Data2, ref data2, value); 
      } 
     } 

     public MainViewModel() 
     { 
      Data2 = new DataTable(); 

      DataColumn testCol = new DataColumn("Test1"); 
      Data2.Columns.Add(testCol); 
      DataRow testRow = Data2.NewRow(); 
      testRow[0] = "0"; 
      Data2.Rows.Add(testRow); 
      Data2.AcceptChanges(); 
     } 
    } 
} 

そして、ここでは私のXAMLである:あなたのための

'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll'. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\Users\William\Documents\Visual Studio 2015\Projects\DatagridTest1\DatagridTest1\bin\Debug\DatagridTest1.vshost.exe'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Net.Http\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Net.Http.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xaml\v4.0_4.0.0.0__b77a5c561934e089\System.Xaml.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\WindowsBase\v4.0_4.0.0.0__31bf3856ad364e35\WindowsBase.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\PresentationCore\v4.0_4.0.0.0__31bf3856ad364e35\PresentationCore.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.dll'. Cannot find or open the PDB file. 
The thread 0x18e8 has exited with code 0 (0x0). 
The thread 0x1e30 has exited with code 0 (0x0). 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\Users\William\Documents\Visual Studio 2015\Projects\DatagridTest1\DatagridTest1\bin\Debug\DatagridTest1.exe'. Symbols loaded. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\Users\William\Documents\Visual Studio 2015\Projects\DatagridTest1\DatagridTest1\bin\Debug\Microsoft.Practices.ServiceLocation.dll'. Symbols loaded. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\Users\William\Documents\Visual Studio 2015\Projects\DatagridTest1\DatagridTest1\bin\Debug\GalaSoft.MvvmLight.Extras.dll'. Symbols loaded. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ComponentModel\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.ComponentModel.dll'. Module was built without symbols. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\Users\William\Documents\Visual Studio 2015\Projects\DatagridTest1\DatagridTest1\bin\Debug\GalaSoft.MvvmLight.dll'. Symbols loaded. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ObjectModel\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.ObjectModel.dll'. Module was built without symbols. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Collections\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Collections.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Reflection\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Reflection.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Threading\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Threading.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Globalization\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Globalization.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Linq\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Linq.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Linq.Expressions\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Linq.Expressions.dll'. Module was built without symbols. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Numerics\v4.0_4.0.0.0__b77a5c561934e089\System.Numerics.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework.Aero2\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.Aero2.dll'. Cannot find or open the PDB file. 
System.Windows.Data Warning: 56 : Created BindingExpression (hash=64505930) for Binding (hash=49162568) 
System.Windows.Data Warning: 58 : Path: 'Data2' 
System.Windows.Data Warning: 61 : BindingExpression (hash=64505930): Default update trigger resolved to PropertyChanged 
System.Windows.Data Warning: 62 : BindingExpression (hash=64505930): Attach to System.Windows.Controls.DataGrid.ItemsSource (hash=59593954) 
System.Windows.Data Warning: 67 : BindingExpression (hash=64505930): Resolving source 
System.Windows.Data Warning: 70 : BindingExpression (hash=64505930): Found data context element: DataGrid (hash=59593954) (OK) 
System.Windows.Data Warning: 71 : BindingExpression (hash=64505930): DataContext is null 
System.Windows.Data Warning: 65 : BindingExpression (hash=64505930): Resolve source deferred 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=Data2; DataItem=null; target element is 'DataGrid' (Name=''); target property is 'ItemsSource' (type 'IEnumerable') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=CellsPanelHorizontalOffset; DataItem=null; target element is 'Button' (Name=''); target property is 'Width' (type 'Double') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=HeadersVisibility; DataItem=null; target element is 'Button' (Name=''); target property is 'Visibility' (type 'Visibility') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=HeadersVisibility; DataItem=null; target element is 'DataGridColumnHeadersPresenter' (Name=''); target property is 'Visibility' (type 'Visibility') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=NonFrozenColumnsViewportHorizontalOffset; DataItem=null; target element is 'ColumnDefinition' (HashCode=15863087); target property is 'Width' (type 'GridLength') 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework-SystemXml\v4.0_4.0.0.0__b77a5c561934e089\PresentationFramework-SystemXml.dll'. Cannot find or open the PDB file. 
System.Windows.Data Warning: 67 : BindingExpression (hash=64505930): Resolving source 
System.Windows.Data Warning: 70 : BindingExpression (hash=64505930): Found data context element: DataGrid (hash=59593954) (OK) 
System.Windows.Data Warning: 78 : BindingExpression (hash=64505930): Activate with root item MainViewModel (hash=66305805) 
System.Windows.Data Warning: 108 : BindingExpression (hash=64505930): At level 0 - for MainViewModel.Data2 found accessor RuntimePropertyInfo(Data2) 
System.Windows.Data Warning: 104 : BindingExpression (hash=64505930): Replace item at level 0 with MainViewModel (hash=66305805), using accessor RuntimePropertyInfo(Data2) 
System.Windows.Data Warning: 101 : BindingExpression (hash=64505930): GetValue at level 0 from MainViewModel (hash=66305805) using RuntimePropertyInfo(Data2): DataTable (hash=35951058) 
System.Windows.Data Warning: 80 : BindingExpression (hash=64505930): TransferValue - got raw value DataTable (hash=35951058) 
System.Windows.Data Warning: 82 : BindingExpression (hash=64505930): TransferValue - user's converter produced DataTable (hash=35951058) 
System.Windows.Data Warning: 84 : BindingExpression (hash=64505930): TransferValue - implicit converter produced DataView (hash=35751240 Count=1) 
System.Windows.Data Warning: 89 : BindingExpression (hash=64505930): TransferValue - using final value DataView (hash=35751240 Count=1) 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework-SystemData\v4.0_4.0.0.0__b77a5c561934e089\PresentationFramework-SystemData.dll'. Cannot find or open the PDB file. 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=AreRowDetailsFrozen; DataItem=null; target element is 'DataGridDetailsPresenter' (Name=''); target property is 'SelectiveScrollingOrientation' (type 'SelectiveScrollingOrientation') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=HeadersVisibility; DataItem=null; target element is 'DataGridRowHeader' (Name=''); target property is 'Visibility' (type 'Visibility') 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Resources.ResourceManager\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Resources.ResourceManager.dll'. Cannot find or open the PDB file. 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=Test1; DataItem=null; target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=ValidationErrorTemplate; DataItem=null; target element is 'Control' (Name=''); target property is 'Template' (type 'ControlTemplate') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=(0); DataItem=null; target element is 'Control' (Name=''); target property is 'Visibility' (type 'Visibility') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=NewItemMargin; DataItem=null; target element is 'DataGridRow' (Name=''); target property is 'Margin' (type 'Thickness') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=AreRowDetailsFrozen; DataItem=null; target element is 'DataGridDetailsPresenter' (Name=''); target property is 'SelectiveScrollingOrientation' (type 'SelectiveScrollingOrientation') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=HeadersVisibility; DataItem=null; target element is 'DataGridRowHeader' (Name=''); target property is 'Visibility' (type 'Visibility') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=Test1; DataItem=null; target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=ValidationErrorTemplate; DataItem=null; target element is 'Control' (Name=''); target property is 'Template' (type 'ControlTemplate') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=(0); DataItem=null; target element is 'Control' (Name=''); target property is 'Visibility' (type 'Visibility') 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework-SystemXmlLinq\v4.0_4.0.0.0__b77a5c561934e089\PresentationFramework-SystemXmlLinq.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework-SystemCore\v4.0_4.0.0.0__b77a5c561934e089\PresentationFramework-SystemCore.dll'. Cannot find or open the PDB file. 
System.Windows.Data Information: 42 : BindingExpression path error: 'Test1' property not found for 'object' because data item is the NewItemPlaceholder. BindingExpression:Path=Test1; DataItem='NamedObject' (HashCode=50804710); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String') 
System.Windows.Data Information: 20 : BindingExpression cannot retrieve value due to missing information. BindingExpression:Path=Test1; DataItem='NamedObject' (HashCode=50804710); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String') 
System.Windows.Data Information: 21 : BindingExpression cannot retrieve value from null data item. This could happen when binding is detached or when binding to a Nullable type that has no value. BindingExpression:Path=Test1; DataItem='NamedObject' (HashCode=50804710); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=Test1; DataItem='NamedObject' (HashCode=50804710); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String') 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CLIENTDIAGNOSTICS\XAMLDIAGNOSTICS\x86\WpfXamlDiagnosticsTap.dll'. Cannot find or open the PDB file. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC\Microsoft.VisualStudio.OLE.Interop\7.1.40304.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.OLE.Interop.dll'. Module was built without symbols. 
'DatagridTest1.vshost.exe' (CLR v4.0.30319: DatagridTest1.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\UIAutomationTypes\v4.0_4.0.0.0__31bf3856ad364e35\UIAutomationTypes.dll'. Cannot find or open the PDB file. 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=NewItemMargin; DataItem=null; target element is 'DataGridRow' (Name=''); target property is 'Margin' (type 'Thickness') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=AreRowDetailsFrozen; DataItem=null; target element is 'DataGridDetailsPresenter' (Name=''); target property is 'SelectiveScrollingOrientation' (type 'SelectiveScrollingOrientation') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=HeadersVisibility; DataItem=null; target element is 'DataGridRowHeader' (Name=''); target property is 'Visibility' (type 'Visibility') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=Test1; DataItem=null; target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=ValidationErrorTemplate; DataItem=null; target element is 'Control' (Name=''); target property is 'Template' (type 'ControlTemplate') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=(0); DataItem=null; target element is 'Control' (Name=''); target property is 'Visibility' (type 'Visibility') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=Test1; DataItem='DataRowView' (HashCode=55668938); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=Test1; DataItem=null; target element is 'TextBox' (Name=''); target property is 'Text' (type 'String') 
System.Windows.Data Information: 41 : BindingExpression path error: 'Test1' property not found for 'object' because data item is null. This could happen because the data provider has not produced any data yet. BindingExpression:Path=Test1; DataItem=null; target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String') 
System.Windows.Data Information: 20 : BindingExpression cannot retrieve value due to missing information. BindingExpression:Path=Test1; DataItem=null; target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String') 
System.Windows.Data Information: 21 : BindingExpression cannot retrieve value from null data item. This could happen when binding is detached or when binding to a Nullable type that has no value. BindingExpression:Path=Test1; DataItem=null; target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=Test1; DataItem=null; target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=Test1; DataItem='DataRowView' (HashCode=55668938); target element is 'TextBox' (Name=''); target property is 'Text' (type 'String') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=Test1; DataItem='DataRowView' (HashCode=55668938); target element is 'DataGridCell' (Name=''); target property is 'CellContent' (type 'String') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=Test1; DataItem=null; target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String') 
System.Windows.Data Information: 41 : BindingExpression path error: 'Test1' property not found for 'object' because data item is null. This could happen because the data provider has not produced any data yet. BindingExpression:Path=Test1; DataItem=null; target element is 'TextBox' (Name=''); target property is 'Text' (type 'String') 
System.Windows.Data Information: 20 : BindingExpression cannot retrieve value due to missing information. BindingExpression:Path=Test1; DataItem=null; target element is 'TextBox' (Name=''); target property is 'Text' (type 'String') 
System.Windows.Data Information: 21 : BindingExpression cannot retrieve value from null data item. This could happen when binding is detached or when binding to a Nullable type that has no value. BindingExpression:Path=Test1; DataItem=null; target element is 'TextBox' (Name=''); target property is 'Text' (type 'String') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=Test1; DataItem=null; target element is 'TextBox' (Name=''); target property is 'Text' (type 'String') 
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=Test1; DataItem='DataRowView' (HashCode=55668938); target element is 'DataGridRow' (Name=''); target property is 'NoTarget' (type 'Object') 

ありがとう:

<Window x:Class="DatagridTest1.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:local="clr-namespace:DatagridTest1" 
     xmlns:diagnostics="clr-namespace:System.Diagnostics;assembly=WindowsBase" 
     mc:Ignorable="d" 
     Title="MainWindow" Height="350" Width="525"> 
    <Grid Focusable="False"> 
     <Grid.Resources> 
      <local:Debug x:Key="Debugger"/> 
     </Grid.Resources> 
<DataGrid VirtualizingPanel.IsVirtualizing="False" HeadersVisibility="None" AutoGenerateColumns="True" ItemsSource="{Binding Data2, diagnostics:PresentationTraceSources.TraceLevel=High, Mode=TwoWay, Converter={StaticResource Debugger}}" DataContext="{Binding Main, Source={StaticResource Locator}}"> 
     </DataGrid> 
    </Grid> 
</Window> 

そして、ここでは私が得るエラーの一種であります助けて!

答えて

0

WPFでSystem.Data名前空間クラスを使用しないでください。適切なINotifyProperyChanged実装を使用して独自のモデルを作成し、ObservableCollectionをリストとして使用します。

ただし、DataTableを使用する場合は、this postを参照してください。 (DataTable.DefaultViewプロパティがキーであるようです)

+0

ありがとうございました。私はすでにDataTable.DefaultViewを試してみたが、それは問題を解決しなかったことを言い忘れた。私はObservableCollectionを使用しようとします。 DataTableを使用した理由は、列と行の追加が容易だったからです。私は拡張可能なスプレッドシートを作ろうとしています。 – Will

関連する問題