Windows 10移动版(UWP)上的ContentDialog宽度拟合

用户4931847

我在Windows 10移动版上为UWP创建了内容对话框。适合在320 x 480分辨率的4“模拟器上完美运行。但是,当我选择5” 720p模拟器时,左右之间会出现间隙。我找不到确切的解决方案。有人遇到这个问题吗?谢谢。

ContentDialog的XAML在这里:

<ContentDialog x:Name="ContDial"
        x:Class="TripLog.UserControls.AddStory"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:TripLog.UserControls"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        Title="Share Story"
        PrimaryButtonText="Share"
        SecondaryButtonText="Cancel"
        PrimaryButtonClick="ContentDialog_PrimaryButtonClick"
        SecondaryButtonClick="ContentDialog_SecondaryButtonClick" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Loading="ContentDialog_Loading" Loaded="ContentDialog_Loaded" Closed="ContentDialog_Closed" Closing="ContentDialog_Closing" RequestedTheme="Light" FontSize="16" MaxWidth="{Binding ActualWidth, ElementName=pageRoot}" MinWidth="500" FullSizeDesired="True">

        <Grid x:Name="Main" ScrollViewer.VerticalScrollBarVisibility="Auto">
            <Grid.RowDefinitions>
                <RowDefinition Height="58"/>
                <RowDefinition Height="58"/>
                <RowDefinition/>
                <RowDefinition Height="76"/>
            </Grid.RowDefinitions>
            <TextBox x:Name="Title_TextBox" Text="" Margin="10,10,10,0" PlaceholderText="Please enter your story title..." RequestedTheme="Light" FontSize="16" MaxLength="50" Grid.Row="1" BorderBrush="{StaticResource TextColor}"/>
            <TextBox x:Name="Experience_Text" Text="" Grid.Row="2" Margin="10,10,10,0"  PlaceholderText="Please tell your experience..." MaxLength="500" TextChanged="Experience_Text_TextChanged" FontSize="16" TextWrapping="Wrap" MinHeight="42" AcceptsReturn="True" RequestedTheme="Light" ScrollViewer.VerticalScrollBarVisibility="Auto" VerticalAlignment="Center" Height="190" BorderBrush="{StaticResource TextColor}"/>
            <Grid x:Name="CharacterGrid" Grid.Row="3" Margin="10,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="48"/>
                    <ColumnDefinition Width="64"/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <TextBlock x:Name="CharacterLeft" Margin="0" TextWrapping="Wrap" Text="" TextAlignment="Right" FontSize="16" Grid.Column="2" VerticalAlignment="Top" RequestedTheme="Light" Foreground="{StaticResource TextColor}"/>
                <Button x:Name="CameraButton" FontFamily="Segoe MDL2 Assets" Content="&#xE722;" Background="Transparent" VerticalAlignment="Top" Margin="0,5,0,0" HorizontalAlignment="Left" Foreground="{StaticResource TextColor}" FontSize="21.333" RequestedTheme="Light" Width="48" Height="48"/>
            </Grid>
            <Grid x:Name="LocationGrid" Margin="10,10,10,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition Width="48"/>
                </Grid.ColumnDefinitions>
                <TextBlock x:Name="LocText" Margin="0" TextWrapping="Wrap" Text="Location will be here...." FontSize="16" VerticalAlignment="Center" RequestedTheme="Light" Foreground="{StaticResource TextColor}" TextAlignment="Center"/>
                <Button x:Name="LocationButton" FontFamily="Segoe MDL2 Assets" Content="&#xE81D;" Background="Transparent" VerticalAlignment="Center" Margin="0" HorizontalAlignment="Right" Foreground="{StaticResource TextColor}" FontSize="21.333" RequestedTheme="Light" Width="48" Height="48" Grid.Column="1"/>
            </Grid>
        </Grid>
    </ContentDialog>

这是图像:

图

Alan Yao - MSFT

在后面的代码中将MinWidth和MaxWidth设置为页面的ActualWidth,以确保它适合屏幕。

例如,如果在按钮内显示对话框,请单击页面。下面的代码应该工作:

private async void Button_Click(object sender, RoutedEventArgs e)
{
    CustomContentDialog contentDialog = new CustomContentDialog();
    contentDialog.MinWidth = this.ActualWidth;
    contentDialog.MaxWidth = this.ActualWidth;
    ContentDialogResult result = await contentDialog.ShowAsync();
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Windows 10移动版(UWP)在ContentDialog上的键盘行为

来自分类Dev

仅针对Windows 10移动版的Windows 10 UWP

来自分类Dev

PickSaveFileAndContinue:Windows 10移动版上的UnauthorizedAccessException

来自分类Dev

日历选择器锁定在屏幕上的Windows 10移动版(UWP)弹出

来自分类Dev

Windows 10移动版UWP-慢速后退按钮

来自分类Dev

在 Windows 10 移动版中启动 UWP 应用时出错

来自分类Dev

Windows 10移动版上的SQLite无法正常工作

来自分类Dev

在Windows 10移动版上处理底部导航栏

来自分类Dev

如何将Qt应用程序部署到UWP或Windows 10移动版

来自分类Dev

UWP / Windows 10移动版中的System.Threading.Thread替换

来自分类Dev

后台任务 Windows 10 移动版 (UWP) 中的 Http 错误

来自分类Dev

Windows.System.LaunchUriAsync仅在Windows 10移动版上引发异常

来自分类Dev

防止Windows 10移动版锁定

来自分类Dev

无法在Windows 10移动版上部署

来自分类Dev

Windows 10 IoT上的UWP

来自分类Dev

在Windows Phone 8、8.1和10(移动版)上创建共享按钮

来自分类Dev

WP 8.1 XAML应用在MapControl上的Windows 10移动版上节省了时间

来自分类Dev

Windows 10移动版:访问设备日志(例如Android上的logcat)

来自分类Dev

如何在 Windows 10 移动版上更新旁加载的 APPX

来自分类Dev

QEMU上的Windows 10专业版

来自分类Dev

如何在真实设备(移动设备)上开发Windows 10 UWP?

来自分类Dev

Windows 10移动版软键盘的高度

来自分类Dev

Windows 10移动版错误:DEP6200

来自分类Dev

在Windows 10移动版中拨打电话

来自分类Dev

在Windows 10移动版中读取图像时出错

来自分类Dev

Windows 10的最小宽度

来自分类Dev

Windows 10 UWP可以在Windows 8.1设备上运行吗?

来自分类Dev

Windows 10 UWP应用:通过移动宽带的StreamSocket

来自分类Dev

在Windows 10移动版中访问IR /虹膜扫描仪/ Windows Hello设备

Related 相关文章

  1. 1

    Windows 10移动版(UWP)在ContentDialog上的键盘行为

  2. 2

    仅针对Windows 10移动版的Windows 10 UWP

  3. 3

    PickSaveFileAndContinue:Windows 10移动版上的UnauthorizedAccessException

  4. 4

    日历选择器锁定在屏幕上的Windows 10移动版(UWP)弹出

  5. 5

    Windows 10移动版UWP-慢速后退按钮

  6. 6

    在 Windows 10 移动版中启动 UWP 应用时出错

  7. 7

    Windows 10移动版上的SQLite无法正常工作

  8. 8

    在Windows 10移动版上处理底部导航栏

  9. 9

    如何将Qt应用程序部署到UWP或Windows 10移动版

  10. 10

    UWP / Windows 10移动版中的System.Threading.Thread替换

  11. 11

    后台任务 Windows 10 移动版 (UWP) 中的 Http 错误

  12. 12

    Windows.System.LaunchUriAsync仅在Windows 10移动版上引发异常

  13. 13

    防止Windows 10移动版锁定

  14. 14

    无法在Windows 10移动版上部署

  15. 15

    Windows 10 IoT上的UWP

  16. 16

    在Windows Phone 8、8.1和10(移动版)上创建共享按钮

  17. 17

    WP 8.1 XAML应用在MapControl上的Windows 10移动版上节省了时间

  18. 18

    Windows 10移动版:访问设备日志(例如Android上的logcat)

  19. 19

    如何在 Windows 10 移动版上更新旁加载的 APPX

  20. 20

    QEMU上的Windows 10专业版

  21. 21

    如何在真实设备(移动设备)上开发Windows 10 UWP?

  22. 22

    Windows 10移动版软键盘的高度

  23. 23

    Windows 10移动版错误:DEP6200

  24. 24

    在Windows 10移动版中拨打电话

  25. 25

    在Windows 10移动版中读取图像时出错

  26. 26

    Windows 10的最小宽度

  27. 27

    Windows 10 UWP可以在Windows 8.1设备上运行吗?

  28. 28

    Windows 10 UWP应用:通过移动宽带的StreamSocket

  29. 29

    在Windows 10移动版中访问IR /虹膜扫描仪/ Windows Hello设备

热门标签

归档