I create a popup in my windows phone 8 application but my popup take only 1/2 of the width screen, why ?
Xmal of my popup :
<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 :
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.