【问题标题】:How to make a 100% input dialog using XAML in WinRT如何在 WinRT 中使用 XAML 创建 100% 输入对话框
【发布时间】:2012-10-29 18:05:02
【问题描述】:

我想创建一个简单的输入对话框,但我很难让它拉伸到屏幕宽度的 100%(我可以手动设置宽度,这不是我想要做的)。我试过水平拉伸,我试过设置左右边距(希望它将两端锚定到边距),我试过用“*”宽度在网格中指定 RowDefintiions。我可以在 XAML 编辑器中看到弹出窗口看起来是屏幕宽度的 100%,但网格不是。

以下面为例。我希望弹出窗口和/或网格在屏幕上跨越 100% 的宽度。有没有一种简单的方法可以做到这一点?

<Page
x:Class="TimeCalculator.BlankPage1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TimeCalculator"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">

    <Popup x:Name="pop" IsOpen="True" Margin="0,0,0,0">
        <Grid x:Name="popGrid" Background="Green" HorizontalAlignment="Stretch">
            <TextBlock Text="This is the popup where I will ask for input" HorizontalAlignment="Stretch"></TextBlock>
        </Grid>
    </Popup>

</Grid>

【问题讨论】:

    标签: xaml windows-runtime


    【解决方案1】:

    试试

    popGrid.Width = Window.Current.Bounds.Width;
    

    【讨论】:

    • 这并没有让我安静下来……但你确实让我走上了正确的道路。在上面的例子中,这条线确实有效“popGrid.Width = Window.Current.Bounds.Width;”。 Window.Current.Bounds.Width 成功了,所以我会接受这个答案。
    猜你喜欢
    • 1970-01-01
    • 2018-02-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多