如何在C#的Metro风格应用中将弹出窗口居中 [英] How to center Popup in Metro style app in c#

查看:73
本文介绍了如何在C#的Metro风格应用中将弹出窗口居中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以显示以Windows 8 Metro为中心的弹出窗口?

Is there any way to show a Popup in Windows 8 Metro centered?

VerticalAlignmentHorizontalAlignment设置为居中",并且将VerticsalOffsetHorizontalOffset设置为0会导致在屏幕中心的左上角弹出提示.

Setting VerticalAlignment and HorizontalAlignment to "Center", and VerticsalOffset and HorizontalOffset to 0 causes howing popup with left-up corner in the center of the screen.

有什么办法可以很好地做到这一点?

Is there any way to do it nicely?

为使此问题更难,此弹出窗口在快照视图中具有不同的大小,也应居中放置.

To make this problem harder, this popup has different size in snapped view, where is also should be centered.

有什么想法吗?

推荐答案

我将其放在Xaml中主网格的末尾,在所有其他内容之后都放在了最前面.

I put this at the end of the main Grid in my Xaml, after everything else so it's sure to come to the front.

<Canvas x:Name="pCanvas" HorizontalAlignment="Center" VerticalAlignment="Center">
    <StackPanel x:Name="pStackPanel">

        <TextBlock x:Name="pText" Text="Enter Name of Playlist:" Margin="25,12" Width="300" />

        <TextBox x:Name="pInputBox" Margin="25,12" Width="300" />

        <Button x:Name="pButton" Content="OK" Height="30" Width="100" Click="pButton_Clicked" Margin="6,12" />

    </StackPanel>
</Canvas>

这篇关于如何在C#的Metro风格应用中将弹出窗口居中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆