Popup Windows phone 8

本文关键字:phone Windows Popup | 更新日期: 2023-09-27 18:08:16

我在windows phone 8应用程序中创建了一个弹出窗口,但是我的弹出窗口只占屏幕宽度的1/2,为什么?

我的弹出窗口:

<UserControl x:Class="PhoneApp1.PopupRename"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}" d:DesignWidth="480" d:DesignHeight="170">
<Grid x:Name="LayoutRoot" Background="{StaticResource PhoneChromeBrush}">
    <Grid.RowDefinitions>
        <RowDefinition Height="80"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <Button x:Name="CancelButton" Content="Cancel" Margin="0,0,0,0" VerticalAlignment="Top" Grid.Row="1" Grid.Column="0"/>
    <Button x:Name="ValideButton" Content="Valider" Margin="0,0,0,0" VerticalAlignment="Top" Grid.Row="1" Grid.Column="1"/>
    <TextBox x:Name="ValueTextBox"  Margin="0,5,0,5" TextWrapping="Wrap" Text="" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" />
</Grid>

我使用以下c#代码:

 Popup renamePopup = new Popup();
            renamePopup.VerticalOffset = 100;
            renamePopup.HorizontalOffset = 10;
            PopupRename popupRename = new PopupRename();
            renamePopup.Child = popupRename;
            renamePopup.IsOpen = true;
            popupRename.ValideButton.Click += (s, args) =>
            {
                renamePopup.IsOpen = false;
                //this.text.Text = Mycontrol.tbx.Text;
            };
            popupRename.CancelButton.Click += (s, args) => { renamePopup.IsOpen = false; };

Popup Windows phone 8

你必须设置你的弹出宽度为全宽度:

Width = (Application.Current.RootVisual as PhoneApplicationFrame).ActualWidth

在您的示例中,您还可以使用LayoutRoot。ActualWidth