Mahapps弹出模态覆盖整个窗口

时间:2016-10-27 00:18:45

标签: .net wpf vb.net xaml mahapps.metro

嘿,当我把 IsModal =“True”时,我似乎对弹出窗口有一些问题。

这是我的XAML:

<Controls:MetroWindow x:Name="frmCR" x:Class="MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:newRP"
        xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
        mc:Ignorable="d" Height="768" Width="1336" ResizeMode="NoResize" ShowInTaskbar="False" WindowStartupLocation="CenterScreen" IsWindowDraggable="False" IsTabStop="False" IsMinButtonEnabled="False" IsMaxRestoreButtonEnabled="False" IsCloseButtonEnabled="False" ShowCloseButton="False" ShowDialogsOverTitleBar="False" ShowIconOnTitleBar="False" ShowMinButton="False" ShowMaxRestoreButton="False" ShowSystemMenuOnRightClick="False" ShowTitleBar="False" TitlebarHeight="0" WindowStyle="None" Title="frmCashRegister">
    <Grid>
        <Button x:Name="button" Content="Button" HorizontalAlignment="Left" Margin="134,95,0,0" VerticalAlignment="Top" Width="75"  Style="{StaticResource AccentedSquareButtonStyle}"/>
        <Controls:FlyoutsControl x:Name="flyoutsControl">
            <Controls:Flyout AnimateOpacity="True" TitleVisibility="Collapsed" CloseButtonVisibility="Collapsed" IsModal="True" Header="Flyout" Position="Bottom" Width="200" x:Name="yourMahAppFlyout">
                <Grid>
                    <TextBlock FontSize="24">Hello World</TextBlock>
                    <Button Grid.Column="2" Style="{DynamicResource MetroFlatButton}" Margin="5" Width="100" Height="30" IsCancel="True" Content="_Close" Click="TopFlyoutCloseButtonOnClick" />
                </Grid>
            </Controls:Flyout>            
        </Controls:FlyoutsControl>
    </Grid>
</Controls:MetroWindow>

这就是弹出后的样子:

enter image description here

它覆盖了表单的完整窗口,我无法点击按钮关闭它。

我做错了什么?

1 个答案:

答案 0 :(得分:2)

我认为您必须将Flyout添加到<Controls:MetroWindow.Flyouts><Controls:FlyoutsControl>

<Controls:MetroWindow ...>
    <Controls:MetroWindow.Flyouts>
        <Controls:FlyoutsControl>
...
        </Controls:FlyoutsControl>
    </Controls:MetroWindow.Flyouts>
相关问题