WPF窗口立即被最小化

时间:2012-04-24 13:24:08

标签: c# wpf c++-cli

解决方案 here

我被要求使用WPF窗口模拟Windows窗体上下文菜单。我在用户点击某个区域时创建了一个窗口,但该窗口立即被最小化到任务栏。我需要它至少在它失去焦点或停用之前保持在其他窗口的顶部。它的窗口样式为none,并且它在任务栏属性中的显示是真还是假并不重要。 SO上也存在类似的问题,但在我的案例中似乎没有解决任何问题。为何这种奇怪的行为?它有解决方法吗?

<Window x:Class="InterceptRouteWindow"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  Width="200" ResizeMode="NoResize" SizeToContent="Height" ShowInTaskbar="False" Loaded="Window_Loaded" WindowStyle="None" Height="auto" Deactivated="Window_Deactivated">


        <StackPanel Height="auto" Name="stackPanel1" Width="200" Background="WhiteSmoke">
             <Separator Height="5"  FlowDirection="LeftToRight">
               <Separator.Background>
                 <SolidColorBrush />
               </Separator.Background>
            </Separator>
      </StackPanel>
</Window>

所以这是一个简单的窗口。我调用它的方式:

 IRWindow = gcnew InterceptRouteWindow(routes, fpId, offsetPoint.x, offsetPoint.y);
 GetMainFrame()->IRWindow->Show();

这是由旧应用程序中的点击事件触发的,MFC和WindowsForms的混合......不是我的代码,我必须遵守他们的设计并尽可能使用WPF。

0 个答案:

没有答案