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# - 检查 url 是否包含 C# 中的某些单词?

c# - 自定义控件的基类

.net - 循环遍历 LINQ 数据的更快方法

c# - 从 C# 应用程序引用 visual basic 命名空间有什么影响?

c++ - CreateThread 后跟 TerminateThread 留下大量内存

c++ - 应用程序无法在 Windows xp 上正确初始化

c# - 如何检查使用 SetThreadExecutionState 禁用 sleep 是否失败?

c# - LINQ to Entities 为实体的 child 的 child 返回错误的 ID

c# - WPF - 使用 DataTemplate 时通过键入选择 ComboBox 值

c# - .NET 中性能至上且数据形式不重要的场景的最佳序列化?