WPF Frame Inside StackPanel not firing events
I dynamically create a frame and add it to the children of the stackpanel. The mouse events were working fine, but have stopped for some reason. Any help is appreciated. Here's where I create them:
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
is an empty StackPanel
in the main window. In the e开发者_运维百科vent handler, I just create a variable and I put a stop on it. It never fires.
Your frame might not be hit-able because it has not background. Have you tried setting the background?
Your mouse clicks might be swallowed by child-elements, using PreviewMouseDoubleClick
instead might help.
I found out why. I added some new overloaded scrollbar code for the scrollviewer and it was catching stuff. Thanks guys.
精彩评论