2013-01-22 2 views
1

Lync SDK에서 작업 중이며 SelectionMode="Single"과 함께 ContactSearchResultList (listBox)를 사용하고 있습니다.ListBox에서 마우스 오른쪽 단추를 클릭했을 때 SelectedItems 오류가 발생했습니다.

하지만 바로 다음과 같은 스택 추적과 함께 응용 프로그램이 충돌을 선택하지 않은 항목을 클릭 할 때 :

System.InvalidOperationException wurde nicht behandelt. 
    HResult=-2146233079 
    Message=Can only change SelectedItems collection in multiple selection modes. Use SelectedItem in single select modes. 
    Source=PresentationFramework 
    StackTrace: 
     bei System.Windows.Controls.Primitives.Selector.OnSelectedItemsCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e) 
     bei System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) 
     bei System.Collections.ObjectModel.ObservableCollection`1.ClearItems() 
     bei System.Windows.Controls.SelectedItemCollection.ClearItems() 
     bei System.Collections.ObjectModel.Collection`1.Clear() 
     bei Microsoft.Lync.Controls.UCListBoxItem.OnMouseRightButtonDown(MouseButtonEventArgs e) 
     bei System.Windows.UIElement.OnMouseRightButtonDownThunk(Object sender, MouseButtonEventArgs e) 
     bei System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) 
     bei System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) 
     bei System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) 
     bei System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) 
     bei System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent) 
     bei System.Windows.UIElement.OnMouseDownThunk(Object sender, MouseButtonEventArgs e) 
     bei System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) 
     bei System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) 
     bei System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) 
     bei System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) 
     bei System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) 
     bei System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args) 
     bei System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted) 
     bei System.Windows.Input.InputManager.ProcessStagingArea() 
     bei System.Windows.Input.InputManager.ProcessInput(InputEventArgs input) 
     bei System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport) 
     bei System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel) 
     bei System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled) 
     bei System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) 
     bei MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) 
     bei MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) 
     bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) 
     bei MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler) 
     bei System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) 
     bei MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) 
     bei MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) 
     bei System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) 
     bei System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) 
     bei System.Windows.Threading.Dispatcher.Run() 
     bei System.Windows.Application.RunDispatcher(Object ignore) 
     bei System.Windows.Application.RunInternal(Window window) 
     bei System.Windows.Application.Run(Window window) 
     bei System.Windows.Application.Run() 
     bei LyncPresenceBrowser.App.Main() in D:\_effexx\_Kunden\DFG\LyncPresenceBrowser\obj\x86\Debug\App.g.cs:Zeile 0. 
     bei System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) 
     bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) 
     bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 
     bei System.Threading.ThreadHelper.ThreadStart_Context(Object state) 
     bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
     bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
     bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
     bei System.Threading.ThreadHelper.ThreadStart() 
    InnerException: 
왜이 오류를 던지고있다

? 제 강령의 어떤 시점에서도 SelectedItems으로 연락을 드리겠습니다. 저는 항상 SelectedItem을 사용합니다. 붙어 임은, 저를 도와주세요 :)

//를 Heres는 경우 : 그것은 contactSearchResultListSelectionMode의 기본값처럼 보인다

public void contactSearchResultList1_SelectionChanged(object sender, SelectionChangedEventArgs e) 
{ 
    if (contactSearchResultList1.SelectedItem != null && contactSearchResultList1.SelectedIndex != -1) 
    { 
     expander1.IsEnabled = true; 
     expander2.IsEnabled = true; 
     expander1.IsExpanded = true; 
     showGroupMembersWindow(); 
    } 
    else 
    { 
     expander1.IsEnabled = false; 
     expander2.IsEnabled = false; 
     //closeGroupMembersWindow(); 
     //closeContactCardWindow(); 
    } 
} 
+0

'다중 선택'으로 설정된 속성을 찾을 수 없습니다. 어떤 응용 프로그램 코드의 일부를 표시할지 모릅니다. 스택 추적에 따르면 일부 기본 동작처럼 보이기 때문에 예외가 발생하기 때문입니다. 'SelectedItem'과 관련된 프로그램 내 모든 부분에 주석을 달았지만 에러는 여전히 나타납니다 ... – MartiniMoe

+1

OnMouse Click Event는 어떻습니까? 당신은 그 코드를 보여줄 수 있습니까 ..? – MethodMan

+0

나는 모른다 ... 나는 단지 SelectionChanged 이벤트를 사용한다. 질문에 코드를 추가했습니다. – MartiniMoe

답변

0

Extended입니다. 나는 그 가치를 바꾸었고 지금은 모든 것이 작동하는 것처럼 보입니다 ... 모든 도움에 감사드립니다!