【问题标题】:Popup Windows phone 8弹出窗口电话 8
【发布时间】:2014-06-12 15:08:28
【问题描述】:

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

我的弹出窗口的 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>

我使用这个 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; };

【问题讨论】:

    标签: c# xaml windows-phone-8 windows-runtime


    【解决方案1】:

    您必须将弹出窗口宽度设置为全宽:

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

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

    【讨论】:

    • popupRename .Width = ((PhoneApplicationFrame) Application.Current.RootVisual).ActualWidth; 工作!
    猜你喜欢
    • 2016-05-30
    • 2012-01-04
    • 1970-01-01
    • 2015-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-25
    • 2021-09-13
    相关资源
    最近更新 更多