我動態創建一個框架並將其添加到堆棧面板的子項中。鼠標事件工作正常,但由於某種原因停止。任何幫助表示讚賞。這裏就是我創建它們:WPF框架內部StackPanel不會觸發事件
Frame newFrame = new Frame();
Page current = Globals.Static.GetCurrentProcess() as Page;
current.Width = 1199; // Doing this here forces the scaletransform to shrink entire app -- must be done on the page
newFrame.Content = current;
newFrame.Width = 384;
newFrame.Height = 288; // Doing this here will limit the shrunk app's height -- must be done on the frame
newFrame.MouseDoubleClick += new MouseButtonEventHandler(newFrame_MouseDoubleClick);
newFrame.Name = current.Title + "_Frame";
this.stackRunning.Children.Add(newFrame);
Separator newSeparator = new Separator();
newSeparator.Name = current.Title + "_Separator";
this.stackRunning.Children.Add(newSeparator);
stackRunning
是在主窗口中的空白StackPanel
。在事件處理程序中,我只是創建一個變量,然後我停下來。它永遠不會起火。
我試過MouseDown,PreviewMouseDown和PreviewMouseDoubleClick ...都沒有火。這很奇怪......這是工作,突然停止。 – 2011-02-05 16:01:03