WPF:是否可以使用MahApps.Metro在可滚动窗口上创建Flyout?

时间:2015-09-04 06:02:06

标签: c# wpf mahapps.metro flyout

Metro,我已经使用了这几天了,现在希望在底部的可滚动窗口上添加Flyout,就像修复菜单栏一样。有可能吗?

下面是弹出窗口的XAML页面代码,为了临时目的,我现在已经添加了,

<Controls:FlyoutsControl>
            <Controls:Flyout Header="Actions" Name="TestFlyout" VerticalAlignment="Bottom" Position="Top" Width="990" Theme="Adapt">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="20*"></ColumnDefinition>
                        <ColumnDefinition Width="20*"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button Content="Save" Width="70" Height="30" HorizontalAlignment="Left" Grid.Column="0"></Button>
                    <Button Content="Cancel" Width="70" Height="30" HorizontalAlignment="Left" Grid.Column="1"></Button>
                </Grid>
            </Controls:Flyout>
        </Controls:FlyoutsControl>

1 个答案:

答案 0 :(得分:1)

也许你忘记把你的弹出窗口放在弹出窗口中。您应该使用Position="Bottom"而不是VerticalAlignment="Bottom"

<Grid>
    <ScrollViewer Name="scrlMain"
                    CanContentScroll="True"
                    HorizontalScrollBarVisibility="Auto"
                    VerticalScrollBarVisibility="Auto"
                    VerticalAlignment="Stretch">

        <TextBlock Text="Test"></TextBlock>

    </ScrollViewer>

    <Controls:Flyout Header="Actions"
                        Name="TestFlyout"
                        IsOpen="True"
                        Position="Bottom"
                        Width="990"
                        Theme="Adapt">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="20*"></ColumnDefinition>
                <ColumnDefinition Width="20*"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Button Content="Save"
                    Width="70"
                    Height="30"
                    HorizontalAlignment="Left"
                    Grid.Column="0"></Button>
            <Button Content="Cancel"
                    Width="70"
                    Height="30"
                    HorizontalAlignment="Left"
                    Grid.Column="1"></Button>
        </Grid>
    </Controls:Flyout>

</Grid>

希望这有帮助。