c# - 如何在按钮上单击弹出窗口,该按钮位于 uwp 中另一个弹出窗口中的位置

标签 c# .net windows uwp

我在我的 uwp 应用程序中使用弹出控件。我想在单击按钮时显示弹出窗口,而该按钮位于另一个弹出窗口中。 我想要图像中这样的 GUI。

The GUI I need is

谁能帮帮我?

最佳答案

A single object element that declares the content. This must be an object that has UIElement in its hierarchy (plain strings don't work). This can be a container, such as a Panel derived class, so that multiple content items within the Flyout can be arranged in layout.

有关详细信息,请参阅 Flyout class .

因此我们可以向 Flyout 的内容添加另一个 Button。

我们也可以使用 FlyoutPlacementMode枚举设置为 FlyoutBase.Placement将弹出按钮的位置设置在目标元素上方。

例如:

<Button Name="MyButton" VerticalAlignment="Center" HorizontalAlignment="Center"
Content="Open flyout">
<Button.Flyout>
    <Flyout Placement="Right">
        <Grid Width="300" Height="300">
            <Grid.RowDefinitions>
                <RowDefinition  Height="*" />
                <RowDefinition  Height="*" />
                <RowDefinition  Height="*" />
                <RowDefinition  Height="*" />
                <RowDefinition  Height="*" />
            </Grid.RowDefinitions>
            <Button  Grid.Row="0" Content="Open second flyout">
                <Button.Flyout>
                    <Flyout Placement="Left">
                        <Grid Width="300" Height="300">
                            <TextBlock TextWrapping="Wrap" Text="This is some text in a flyout." />
                        </Grid>
                    </Flyout>
                </Button.Flyout>
            </Button>
        </Grid>
    </Flyout>
</Button.Flyout>

如果你想显示项目菜单,请尝试使用MenuFlyout控制。有关更多信息,包括 XAML 和代码示例,请参阅快速入门:Adding a MenuFlyout .

关于c# - 如何在按钮上单击弹出窗口,该按钮位于 uwp 中另一个弹出窗口中的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40932136/

相关文章:

c++ - 有没有用 C++ 编写的开源 PDF 打印机?

c# - 清除 VSCode 中所有断点的命令(如 Visual Studio 中)

c# - 从 XAML 将 ViewModel 传递给用户控件构造函数

c++ - 没有复制文件的 TeamCity 依赖?

c# - SignalR 中打开的连接列表?

c# - 命名空间编写标准和性能问题

java - 查找给定 Windows 版本的最新版本的方法

c# - 按键时的 WPF 即时验证

c# - xy坐标系需要可调整大小的数据类型

c# - 构建 vSphere DLL 失败并出现 CS8078 : An expression is too long or complex to compile