【问题标题】:ContentDialog behavior difference with Creators UpdateContentDialog 与 Creators Update 的行为差异
【发布时间】:2018-01-02 05:12:35
【问题描述】:

我有一个场景,我在视图模型中更改内容对话框的大小。这在 AnniversaryUpdate 中运行良好,但在 Creators Update 中,我得到了完全不同(且不可行)的行为。

我有一个内容对话框,我想根据用户输入将屏幕尺寸从纵向更改为横向。在构建 14393(周年纪念)中,它工作得很好。当我将项目切换为使用 Creators Update (150630) 时,它根本不起作用。

这是导致该问题的 XAML 代码:

<ContentDialog
x:Class="DialogView"
...snip...
Background="LightGray"
MinHeight="{Binding GridHeight}" MinWidth="{Binding GridWidth}">

<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
    <Grid Background="AliceBlue" Visibility="Collapsed"/>
    <Button Content="{Binding Orientation}" Height="40" Click="ToggleButton_Click" VerticalAlignment="Top" HorizontalAlignment="Left"/>
</Grid>

当我为 Creators Update 运行构建时,我得到一个不会改变大小的非常小的对话框。

【问题讨论】:

    标签: dialog uwp-xaml creators-update


    【解决方案1】:

    14393 中 Windows.UI.Xaml.Controls.ContentDialog 的默认样式与 15063 中 Windows.UI.Xaml.Controls.ContentDialog 的默认样式不同。

    在 15063 中 Windows.UI.Xaml.Controls.ContentDialog 的默认样式中,它使用ContentDialogMinHeightContentDialogMinWidth 来设置MinHeightMinWidth。而ContentDialogMinHeightContentDialogMinWidth的默认值分别是184和320。

    当您将值设置为ContentDialog 控件中的MinHeightMinWidth 属性时,它不会更改样式中定义的值。

    在 14393 中,它没有在默认样式中定义 MinHeightMinWidth。如果想在15063中得到和14393一样的MinHeightMinWidth,应该可以复制15063中的默认样式,去掉以下代码:

    <Setter Property = "MinHeight" Value="{ThemeResource ContentDialogMinHeight}" />
    <Setter Property = "MinWidth" Value="{ThemeResource ContentDialogMinWidth}" />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-05
      • 2018-04-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多