0
ThumbnailToolBarButton을 클릭하면 새로운 WPF 응용 프로그램에서 창을 닫으려고합니다 (기본 생성 된 xaml에 대한 변경 사항 없음). 나는 그렇게하려고하면, 나는 다음과 같은 오류가 표시 오전 :ThumbnailToolBarButton을 사용하여 창에서 닫기 닫기를 호출 할 수 없습니다.
using System;
using System.Reflection;
using System.Windows;
using System.Windows.Interop;
using Microsoft.WindowsAPICodePack.Taskbar;
namespace WpfApplication1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
Loaded += new RoutedEventHandler(MainWindow_Loaded);
}
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
ThumbnailToolBarButton thumbCancel = new ThumbnailToolBarButton(System.Drawing.Icon.ExtractAssociatedIcon(Assembly.GetEntryAssembly().Location), "Cancel");
thumbCancel.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(thumbCancel_Click);
TaskbarManager.Instance.ThumbnailToolBars.AddButtons(new WindowInteropHelper(this).Handle, thumbCancel);
}
void thumbCancel_Click(object sender, ThumbnailButtonClickedEventArgs e)
{
Close();
}
}
}
감사 :
System.InvalidOperationException was unhandled
Message=Operation is not valid due to the current state of the object.
Source=WindowsBase
StackTrace:
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.NativeWindow.WndProc(Message& m)
at Microsoft.WindowsAPICodePack.Taskbar.ThumbnailToolbarProxyWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at WpfApplication1.App.Main() in d:\documents\visual studio 2010\Projects\WpfApplication1\WpfApplication1\obj\x86\Debug\App.g.cs:line 0
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
것은 여기 내 코드입니다.
MainWindow 인스턴스와 thumbCancel 인스턴스간에 연결이 표시되지 않습니다. 보기에서이 단추를 보려면 어떻게해야합니까? –
라인 : TaskbarManager.Instance.ThumbnailToolBars.AddButtons (새 WindowInteropHelper (this) .Handle, thumbCancel); 단추를 ThumbnailToolBar에 추가합니다. MainWIndow.xaml.cs의 새 wpf 응용 프로그램에 해당 코드를 모두 추가하고 히트를 재생하면 ThumbnailToolBar에 단추가 표시됩니다. – user1002367