gpt4 book ai didi

xaml - ContentDialog 的大小不适合具有大 TextBlock 的通用应用程序中的内容

转载 作者:行者123 更新时间:2023-12-02 05:12:28 32 4
gpt4 key购买 nike

我正在尝试为通用应用程序构建自定义 ContentDialog。但是,当其中一个文本 block 是多行时,窗口大小会过大。这是布局:

<ContentDialog
x:Class="a2v.ConflictDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:a2v"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="1000"
d:DesignWidth="1000"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
Height="Auto"
Width="Auto"
Title="Conflict">

<Grid Width="Auto" Height="Auto">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.Resources>
<Style x:Key="ButtonStyle" TargetType="Button">
<Setter Property="Background" Value="LightSkyBlue"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
</Style>
</Grid.Resources>
<!--<TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" x:Name="Text" TextAlignment="Justify" Text="ShortText" TextWrapping="WrapWholeWords"/>-->
<TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" x:Name="Text" TextAlignment="Justify" Text="This long text illustrates how the big dialog content make the dialog window size very big. As soon as I change the text to somewhat smaller the empty space below disappears." TextWrapping="WrapWholeWords"/>
<TextBlock Grid.Row="1" Grid.Column="0" Margin="0,15,0,0" Text="Remove conflicting"/>
<TextBlock Grid.Row="1" Grid.Column="1" Margin="30,15,5,0" Text="-" VerticalAlignment="Top"/>
<TextBlock Grid.Row="1" Grid.Column="2" Margin="0,15,0,0" Text="removes." TextWrapping="WrapWholeWords"/>
<TextBlock Grid.Row="2" Grid.Column="0" Text="Resolve conflicting"/>
<TextBlock Grid.Row="2" Grid.Column="1" Margin="30,0,0,0" Text="-" VerticalAlignment="Top" />
<TextBlock Grid.Row="2" Grid.Column="2" Text="resolves." TextWrapping="WrapWholeWords"/>
<TextBlock Grid.Row="3" Grid.Column="0" Text="Cancel" />
<TextBlock Grid.Row="3" Grid.Column="1" Margin="30,0,0,0" Text="-" VerticalAlignment="Top" />
<TextBlock Grid.Row="3" Grid.Column="2" Text="do nothing and return to the previous screen." TextWrapping="WrapWholeWords" />

<Grid Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="3">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Content="Remove conflicting" Margin="15,15,0,15" Style="{StaticResource ButtonStyle}" Tapped="RemoveConflict_OnTapped"/>
<Button Grid.Column="1" Content="Resolve conflicting" Margin="15,15,0,15" Style="{StaticResource ButtonStyle}" Tapped="ResolveConflict_OnTapped"/>
<Button Grid.Column="2" Content="Cancel" Margin="15,15,15,15" Style="{StaticResource ButtonStyle}" Tapped="Cancel_OnTapped"/>
</Grid>
</Grid>
</ContentDialog>

Here is how it looks like with the short text

And here is what happens when the text is long

如何消除对话框底部的空白区域?

最佳答案

尝试向 contentDialog 添加一个 MaxHeight 值。

关于xaml - ContentDialog 的大小不适合具有大 TextBlock 的通用应用程序中的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33038044/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com