2013-12-08 4 views
1

WPF에서 간단한 양식을 작성 중이므로 제대로 작동합니다. 하지만 이제 목표 프레임 워크를 4에서 3.5로 변경해야합니다. 하지만 3.5 버전을 실행하면 예외적으로 실패합니다.창을 숨길 때 InvalidOperationException이 발생합니다.

private void MainWindow_OnLoaded(object sender, RoutedEventArgs e) 
    { 
     _notificator = new Notificator(Directory.GetCurrentDirectory()); 
     _notificator.EventStarted += (o, ev) => Dispatcher.Invoke(new Action(() => 
                     { 
                      new NotificationPage(ev).Show(); 
                      _collection.Remove(ev); 
                     })); 
     _notificator.EventRemoved += (o, ev) => _collection.Remove(ev); 
     _notificator.EventAdded += (o, ev) => _collection.Insert(_notificator.Events.IndexOf(ev), ev); 
     _collection = new ObservableCollection<MyEvent>(_notificator.Events); 
     EventsGrid.DataContext = _collection; 
     _notificator.Start(); 
     LostEventsGrid.DataContext = _notificator.LostEvents; 
     Hide(); 
    } 

내가 모든 방법을 썼다, 그러나 그것은 단지 Two-way binding requires Path or XPath와 숨기기 방법에 실패 그래서 OnLoaded이 같다. 스택 트레이스 :

System.Windows.Data.BindingExpression.CreateBindingExpression (DependencyObject에 d를 DependencyProperty에 DP, 제본 바인딩 BindingExpressionBase 부모) System.Windows.Data.Binding.CreateBindingExpressionOverride (DependencyObject의 타겟 в , DependencyProperty에 DP, BindingExpressionBase в Microsoft.Windows.Controls.DataGridTextColumn в 결합 System.Windows.Data.BindingOperations.SetBinding (DependencyObject의 대상, DependencyProperty에 DP, BindingBase) Microsoft.Windows.Controls.DataGridBoundColumn.ApplyBinding (DependencyObject의 타겟 в , DependencyProperty에 속성) в 소유자) .GenerateElement (DataGridCell 셀, ObjectDataItem) в 마이크로 초 ft.Windows.Controls.DataGridColumn.BuildVisualTree (Boolean isEditing, Object dataItem, DataGridCell 셀) Microsoft.Windows.Controls.DataGridCell.BuildVisualTree() Microsoft.Controls.DataGridCell.PrepareCell (개체 항목, DataGridRow ownerRow, INT32 지수) Microsoft.Windows.Controls.DataGridCell.PrepareCell (개체 항목 System.Windows в Microsoft.Windows.Controls.Primitives.DataGridCellsPresenter.PrepareContainerForItemOverride в ItemsControl에 cellsPresenter, DataGridRow ownerRow) (DependencyObject의 요소, 개체 항목) в . Control.ItemsControl.MS.Internal.Controls.GeneratorHost.PrepareItemContainer (DependencyObject 컨테이너, 개체 항목) в System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.PrepareItemContainer (종속성 객체 컨테이너) Microsoft.Windows.Controls.DataGridCellsPanel.InsertContainer (INT32 childIndex에, UIElement에 컨테이너, 부울 isRecycled) Microsoft.Windows.Controls.DataGridCellsPanel.InsertNewContainer в (INT32 childIndex에, UIElement에 컨테이너) Microsoft.Windows.Controls в в . Microsoft.Windows.Controls.DataGridCellsPanel.GenerateChild в DataGridCellsPanel.AddContainerFromGenerator (INT32 childIndex에, UIElement에 아이, 부울 newlyRealized) (IItemContainerGenerator 발생기, 크기 제약은 DataGridColumn 열, INT32 & childIndex에, 크기 & childSize) Microsoft.Windows.Controls в . DataGridCellsPanel.GenerateChildren (IItemContainerGenerator 생성기, Int32 startIndex, Int32 endIndex, 크기 제약 조건) Microsoft.Windows.Controls. DataGridCellsPanel.GenerateAndMeasureChildrenForRealizedColumns (크기 제한) Microsoft.Windows.Controls.DataGridCellsPanel.MeasureOverride (크기 제한) в System.Windows.FrameworkElement.MeasureCore (크기 availableSize) в System.Windows.UIElement.Measure (크기 availableSize) в в MSControls.ItemsPresenter.MeasureOverride (크기 제한 조건) System.Windows.FrameworkElement.MeasureCore (Size availableSize) System.Windows.UIElement. Measure (Size availableSize) System.Windows.Controls.Control.MeasureOverride (크기 제약 조건) Microsoft.Windows.Controls.Primitives.DataGridCellsPresenter .MeasureOverride (Size availableSize) System.Windows.FrameworkElement.MeasureCore (Size availableSize) System.Windows.UIElement.Measure (Size availableSize) System.Windows.Controls.Grid.MeasureCell (Int32 셀, 부울 forceInfinityV) System.Windows.Controls.Grid.MeasureCellsGroup (INT32 cellsHead, 크기 referenceSize, 부울 ignoreDesiredSizeU, 부울 forceInfinityV) 시스템 в System.Windows.FrameworkElement.MeasureCore в System.Windows.Controls.Grid.MeasureOverride в (크기 제한) (크기 availableSize) . Windows.UIElement.Measure (Size availableSize) System.Windows.Controls.Border.MeasureOverride (크기 제약 조건) System.Windows.FrameworkElement.MeasureCore (크기 availableSize) System.Windows.UIElement.Measure (Size availableSize) System.Windows.Controls.Control.MeasureOverride (크기 제약 조건) System.Windows.FrameworkElement.MeasureCore (크기 availableSize) System.Windows.UIElement.Measure (Size availableSize) System.Windows.Controls.VirtualizingStackPanel.MeasureOverride (크기 제한) в в Microsoft.Windows.Controls.Primitives.DataGridRowsPresenter.MeasureOverride (크기 제한) System.Windows.FrameworkElement.MeasureCore (크기 availableSize) в System.Windows в .UIElement.Measure (크기 availableSize) System.Windows.ContextLayoutManager.UpdateLayout (в ) System.Windows.Interop.HwndSource.Process_WM_SIZE в (UIElement에 rootUIElement, IntPtr입니다 HWND, INT32의 MSG, IntPtr입니다의 wParam, IntPtr입니다의 lParam) 시스템 в . Windows.Interop.HwndSource.LayoutFilterMessage (IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, 부울 & 처리됨) MS.Win32.HwndWrapper.WndProc (IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean,처리) MS.Win32.HwndSubclass.DispatcherCallbackOperation (객체 O) System.Windows.Threading.ExceptionWrapper.InternalRealCall в в (대리인 콜백 인수 개체 부울 isSingleParameter) System.Windows.Threading.ExceptionWrapper.TryCatchWhen в (개체 (delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) System.Windows.Threading.Dispatcher.WrappedInvoke (대리자 콜백, 개체 args, 부울 isSingleParameter, 대리자 catchHandler)System.Windows.Threading.Dispatcher.WrappedInvoke 대리자 콜백, 개체 args, 부울 isSingleParameter) System.Windows.Threading.Dispatcher.InvokeImpl (DispatcherPriority 우선 순위, TimeSpan 시간 제한, 대리 메서드, 개체 args, 부울 isSingleParameter) System.Windows.Threading.Dispatcher.Invoke (DispatcherPriority 우선 순위, 대리 메서드, 개체 arg) MS.Win32.HwndSubclass.SubclassWndProc (IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) в MS.Win32.UnsafeNativeMethods .CallWindowProc (WNDPROC을 IntPtr, HWND를 IntPtr, INT32의 MSG,을 IntPtr의 wParam,을 IntPtr의 lParam) MS.Win32.UnsafeNativeMethods.CallWindowProc в MS.Win32.HwndSubclass.DefWndProcWrapper (HWND를 IntPtr, INT32의 MSG,을 IntPtr의 wParam,을 IntPtr의 lParam) (в 를 IntPtr WNDPROC, HWND를 IntPtr, INT32의 MSG,을 IntPtr의 wParam,을 IntPtr의 lParam) MS.Win32.HwndSubclass.SubclassWndProc в MS.Win32.HwndSubclass.CallOldWindowProc (oldWndProc을 IntPtr, HWND를 IntPtr, INT32의 MSG,을 IntPtr의 wParam,을 IntPtr의 lParam) в (IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)

,363,210
.NET에서

4+가 잘

답변

0

해결 작동 : 문제는 WPF3.5에 존재하지 않는 데이터 그리드를 사용하는, WPFToolkit했다. 그래서 그것을 참조하고, 내부 프레임 워크 대신 WPFToolkit에서 컨트롤을 사용할 때 여전히 .Net 4+에서 오류가 발생합니다.

+0

안녕하세요, 당신은 당신이이 문제를 해결하기 위해 참조 정확하게 조립 무엇 버전 설명해 할 수 있습니까? – MoMo

+0

@MoMo .Net 4.0+ 이상을 사용해야하며 모든 프로젝트에서 WPFToolkit을 참조하지 마십시오. 제 경우에는 효과가있었습니다. –

1

다른이 문제가있을 수 있습니다. 내 문제는 내가 바인딩 경로를 설정하는 방법이었습니다. 내 경로를 연결하고 있었고 체인 변경 사항에 대한 참조가있을 때마다 제어 기능이 연결을 끊어서 Two-way binding requires Path or XPath 예외를 throw합니다.

는 예를 생각해 봅시다 EntityProperty 참조 변경 후 컨트롤이이 경로를 바인딩있어 느슨하게하고 예외가 발생합니다 때마다

<Binding Path="EntityProperty.Name" Mode="TwoWay"> 

.

몇 가지 해결 방법은 다음 게시물을 참조 : https://stackoverflow.com/a/6250988/176728

관련 문제