简体   繁体   English

弹出式Windows Phone 8

[英]Popup Windows phone 8

I create a popup in my windows phone 8 application but my popup take only 1/2 of the width screen, why ? 我在Windows Phone 8应用程序中创建了一个弹出窗口,但是我的弹出窗口仅占用宽度屏幕的1/2,为什么?

Xmal of my popup : 我弹出的Xmal:

<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>

And i use this c# code : 我使用此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; };

You must set your popup width to full width: 您必须将弹出宽度设置为全宽:

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

In your example you also can use LayoutRoot.ActualWidth 在您的示例中,您还可以使用LayoutRoot.ActualWidth

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM