问题描述
有什么方法可以显示以Windows 8 Metro为中心的弹出窗口?
Is there any way to show a Popup in Windows 8 Metro centered?
将VerticalAlignment
和HorizontalAlignment
设置为居中",并且将VerticsalOffset
和HorizontalOffset
设置为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风格应用中将弹出窗口居中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!