.xaml
<Window x:Class="WpfDatagridTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:WpfToolkit="http://schemas.microsoft.com/wpf/2008/toolkit"
Title="Window1" Height="300" Width="300">
<Grid>
<WpfToolkit:DataGrid
x:Name="DataGrid_" ItemsSource="{Binding}"
SelectionMode="Extended"
CanUserAddRows="False" CanUserDeleteRows="False"
CanUserResizeRows="False" CanUserSortColumns="False"
AutoGenerateColumns="False"
RowHeaderWidth="17" RowHeight="25" />
</Grid>
</Window>
.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Windows.Controls;
namespace WpfDatagridTest
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
const int MAX = 10;
for(int i = 0; i < MAX; ++i)
DataGrid_.Columns.Add(new DataGridTextColumn()
{
Header = i
});
DataGrid_.Items.Add("");
}
}
}
이 프로그램은 머리가있는 열 10 개가있는 WPF 툴킷 DataGrid를 보여줍니다. ers와 텅빈 줄.
빈 행의 특정 셀을 선택하고 클릭하여 편집 할 때 문제가 발생합니다. 프로그램이 충돌합니다. Visual Studio에서 "현재 위치에 사용할 수있는 소스 코드가 없습니다."라는 메시지 상자가 나타납니다. 어떻게하면 DataGrid의 셀을 편집 가능하게 만들 수 있습니까? 여기
예외 및 스택 트레이스이다 System.InvalidOperationException 는 처리되지 않은 메시지 = " 'EditItem'는 이러한 관점에서 허용되지 된다."을
소스 = "PresentationFramework"
스택 트레이스 : Microsoft.Windows.Controls.DataGrid.EditRowItem에서 System.Windows.Controls.ItemCollection.System.ComponentModel.IEditableCollectionView.EditItem (객체 항목) 에서 (객체 rowItem)에서 C : \ DD \ WPF_1 \ SRC \ WPF \ SRC \ ControlsPack \ WPFToolkit \ 데이터 그리드는 \ 마이크로 소프트 \ 윈도우 \는 \ DataGrid.cs 제어 : Microsoft.Windows.Controls.DataGrid.OnExecutedBeginEdit에서 라인 (ExecutedRoutedEventArgs 전자)에서를 C : \ dd \ WPF_1 \ src \ wpf \ src \ ControlsPack \ WPFToolkit \ DataGrid \ Microsoft \ Windows \ Controls \ DataGrid.cs : 줄 35에서 Microsoft.Windows.Controls.DataGrid.OnExecutedBeginEdit ( 보낸 사람, ExecutedRoutedEventArgs e) C : \ dd \ WPF_1 \ src \ wpf \ src \ ControlsPack \ WPFToolkit \ DataGrid \ Microsoft \ Windows \ Controls \ DataGrid.cs : System.Windows에서 System.Windows.Input.CommandManager.ExecuteCommandBinding (개체 송신자 ExecutedRoutedEventArgs 즉 CommandBinding을 CommandBinding을) 에서 System.Windows.Input.CommandBinding.OnExecuted (개체 송신자 ExecutedRoutedEventArgs E)에서 라인 2,036 .Input.CommandManager.FindCommandBinding (CommandBindingCollection commandBindings, Object sender, RoutedEventArgs e, ICommand 명령 부울 실행) System.Windows.Input.CommandManager.OnExecuted (개체 송신자 ExecutedRoutedEventArgs E)에서 System.Windows.Input.CommandManager.FindCommandBinding (개체 송신자 RoutedEventArgs 즉 ICommand의 명령 실행 부울) 에서 System.Windows에서 .UIElement.OnExecutedThunk (개체 송신자 ExecutedRoutedEventArgs E) System.Windows.Input.ExecutedRoutedEventArgs.InvokeEventHandler (대리인 genericHandler 오브젝트 대상)에서 System.Windows.RoutedEventArgs 에서 .System.Windows.EventRoute.InvokeHandlersImpl에서 System.Windows.RoutedEventHandlerInfo.InvokeHandler에서의 InvokeHandler (대리인 핸들러 객체 타겟) (개체 대상 RoutedEventArgs routedEventArgs) (개체 소스 RoutedEventArgs 인수, 리 레이즈 부울 )에서 System.Windows.UIElement.RaiseEventImpl (DependencyObject에 보낸 사람, RoutedEventArgs 인수) System.Windows.UIElement.RaiseEvent에서 System.Windows.Input.RoutedCommand.ExecuteImpl에서 (RoutedEventArgs 인수, 부울 신뢰할) (객체 매개 변수 IInputElement 대상 , 부울 userInitiated)Microsoft.Windows.Controls.DataGrid.BeginEdit에서 System.Windows.Input.RoutedCommand.Execute (개체 파라미터 IInputElement 대상)에서 (RoutedEventArgs editingEventArgs)에 C : \ DD \ WPF_1 \ SRC \ WPF \ SRC \ 라인 Microsoft.Windows.Controls.DataGridCell.OnAnyMouseLeftButtonDown에서 3059 (MouseButtonEventArgs 전자) C에서 : ControlsPack \ WPFToolkit \ 데이터 그리드 \ 마이크로 소프트 \ 윈도우 \는 \ DataGrid.cs을 제어 \ DD \ WPF_1 \ SRC \ WPF \ SRC \ ControlsPack \ WPFToolkit \ DataGrid \ Microsoft \ Windows \ Controls \ DataGridCell.cs : Microsoft.Windows.Controls.DataGridCell.OnAnyMouseLeftButtonDownThunk (개체 보낸 사람, MouseButtonEventArgs e)의 C : \ DD \ WPF_1 \ SRC \ WPF \ SRC \ ControlsPack \ WPFToolkit \ 데이터 그리드 \ 마이크로 소프트 \ 윈도우 \는 \ DataGridCell.cs 제어 : System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler (대표 genericHandler에서 라인 (726) 를 개체 System.Windows.EventRoute.InvokeHandlersImpl에서 System.Windows.RoutedEventHandlerInfo.InvokeHandler (개체 대상 RoutedEventArgs routedEventArgs) 에서 System.Windows.RoutedEventArgs.InvokeHandler (대리인 핸들러 오브젝트 대상)에서 genericTarget) (소스 개체 , RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.ReRaiseEventAs (DependencyObject) 63,210 송신자 RoutedEventArgs 인수, RoutedEvent newEvent) System.Windows.UIElement.CrackMouseButtonEventAndReRaiseEvent에서 (DependencyObject에 송신자 MouseButtonEventArgs E)에서 System.Windows System.Windows.UIElement.OnMouseDownThunk (개체 송신자 MouseButtonEventArgs E)에서 . System.Windows.RoutedEventHandlerInfo.InvokeHandler (개체 대상 routedEventArgs routedEventArgs) 에서 System.Windows.RoutedEventArgs.InvokeHandler (대리인 핸들러 오브젝트 대상)에서 Input.MouseButtonEventArgs.InvokeEventHandler (대리인 genericHandler, genericTarget 개체)에서 System.Windows.Eve ntRoute.InvokeHandlersImpl (리 레이즈 객체 소스, RoutedEventArgs 인수, 부울 ) System.Windows.UIElement.RaiseEventImpl에서 (DependencyObject에 보낸 사람, RoutedEventArgs 인수) System.Windows.UIElement.RaiseEvent에서 (RoutedEventArgs 인수, 부울 신뢰할) System.Windows.Input.InputProviderSite.ReportInput에서 System.Windows.Input.InputManager.ProcessInput (InputEventArgs 입력)에서 System.Windows.Input.InputManager.ProcessStagingArea() System.Windows에서 (inputReport inputReport)에서 . Interop.HwndMouseInputProvider.System.Windows.Interop.HwndMouseInputProvider.FilterMessage에서 ReportInput ( 을 IntPtr HWND, INPUTMODE 모드 INT32 소인 RawMouseActions 작업, INT32의 X, Y의 INT32, INT32 휠) ( 을 IntPtr HWND, INT32의 MSG,을 IntPtr의 wParam, 을 IntPtr System.Windows.Interop.HwndSource.InputFilterMessage에서의 lParam 취급 부울 &) ( 을 IntPtr가 HWND, INT32에 MSG가를 IntPtr의 wParam은을 IntPtr 는 lParam의 부울 & 취급) MS.Win32.HwndWrapper.WndProc에서 ( 을 IntPtr HWND, Int32 msg, IntPtr wParam, IntPtr lParam, 부울 & 처리됨) System.Windows.Threading.ExceptionWrapper.InternalRealCall에서 MS.Win32.HwndSubclass.DispatcherCallbackOperation (개체 O) 에서 System.Windows.Threading.ExceptionWrapper.TryCatchWhen (개체 에서 (대리인 콜백 인수 부울 isSingleParameter 개체) 소스, 위임 콜백, 부울 isSingleParameter, 위임 catchHandler) System.Windows.Threading에서 인수 개체, System.Windows.Threading.Dispatcher.WrappedInvoke (위임에 콜백을 인수, 부울 isSingleParameter, 위임 catchHandler) 객체 .Dispatcher.InvokeImpl (DispatcherPriority ) 우선, 타임 아웃 시간 범위는 위임 있어서, MS.Win32.HwndSubclass.SubclassWndProc에서 System.Windows.Threading.Dispatcher.Invoke (DispatcherPriority 우선, 위임 방법, 개체 ARG) 에서 부울 isSingleParameter) 를 인수 개체 (HWND를 IntPtr , INT32의 MSG, System.Windows.Threading에서 System.Windows.Threading.Dispatcher.PushFrameImpl에서 MS.Win32.UnsafeNativeMethods.DispatchMessage을 IntPtr에서의 wParam, 을 IntPtr의 lParam) (MSG & MSG) (DispatcherFrame 프레임) . Dispatcher.PushFrame (DispatcherFrame 프레임) at System.Windows.Threading.Dispatcher.Run()System.Windows.Application.RunDispatcher에서 16,System.Windows.Application에서 System.Windows.Application.Run (창 창) 에서 System.Windows.Application.RunInternal (창 창) 에서 을 ( 무시 객체). C에서 WpfDatagridTest.App.Main()에서 실행() : \ 사용자 \ 프랭크 \ 문서 \ Visual_Studio_2008 \ 프로젝트 \ WpfDatagridTest \ WpfDatagridTest \ OBJ \ 디버그 \ App.g.cs : 라인 System.AppDomain에서. _nExecuteAssembly (어셈블리 어셈블리, 문자열 [] args) at System.AppDomain.ExecuteAssembly (문자열 assemblyFile, 증거 assemblySecurity, String [] a RGS) System.Threading.ExecutionContext.Run (의 ExecutionContext에서 System.Threading.ThreadHelper.ThreadStart_Context (객체 상태) 에서 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 에서 의 ExecutionContext, ContextCallback 콜백 개체 상태) System.Threading.ThreadHelper.ThreadStart에서 () 의 InnerException :
1.3 k 전망 및 upvote 권자 없음 : D – Partial