XAML ContentDialog最大宽度

noj0wjuj  于 2023-04-03  发布在  其他
关注(0)|答案(4)|浏览(155)

我正在尝试在我的应用程序中创建一个设置菜单,如下所示

我知道怎么做,但我有一个问题的宽度对内容对话框,显然有一个限制的宽度。
下面是我的内容对话框的代码:

Title="" Margin="12,0,-12,0" HorizontalAlignment="Stretch" Width="800" Height="600" VerticalAlignment="Stretch" Background="{x:Null}">
<Grid x:Name="Main" ScrollViewer.VerticalScrollBarVisibility="Auto" Width="800">
    <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" />
    <TextBox x:Name="Experience_Text" Text="" Grid.Row="2" Margin="10,10,10,0"  PlaceholderText="Please tell your experience..." MaxLength="500" FontSize="16" TextWrapping="Wrap" MinHeight="42" AcceptsReturn="True" RequestedTheme="Light" ScrollViewer.VerticalScrollBarVisibility="Auto" VerticalAlignment="Center" Height="190" />
    <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" />
        <Button x:Name="CameraButton" FontFamily="Segoe MDL2 Assets" Content="&#xE722;" Background="Transparent" VerticalAlignment="Top" Margin="0,5,0,0" HorizontalAlignment="Left" 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" TextAlignment="Center"/>
        <Button x:Name="LocationButton" FontFamily="Segoe MDL2 Assets" Content="&#xE81D;" Background="Transparent" VerticalAlignment="Center" Margin="0" HorizontalAlignment="Right"  FontSize="21.333" RequestedTheme="Light" Width="48" Height="48" Grid.Column="1"/>
    </Grid>
</Grid>
cig3rfwq

cig3rfwq1#

App.xaml中,尝试将ContentDialogMaxWidth设置为800。默认值为548。您可能还希望增加高度。

<Application.Resources>
    <x:Double x:Key="ContentDialogMaxWidth">800</x:Double>
    <x:Double x:Key="ContentDialogMaxHeight">756</x:Double>
</Application.Resources>
qrjkbowd

qrjkbowd2#

只需在initialize component后添加此代码

this.width = Window.Current.Bounds.Width;

内容对话框将显示屏幕宽度

polkgigr

polkgigr3#

我所要做的就是在初始化组件之后添加以下代码

this.width = Window.Current.Bounds.Width;

和内容对话框将得到您的屏幕宽度。。谢谢大家,希望这将有助于任何人搜索它!

tf7tbtn2

tf7tbtn24#

不,最好单独设计ContentDialogs,只将此添加到内容对话框XAML:

<ContentDialog.Resources>
      <x:Double x:Key="ContentDialogMaxWidth">1200</x:Double>
      <x:Double x:Key="ContentDialogMaxHeight">1000</x:Double>`
</ContentDialog.Resources>

现在你可以为你的ContentDialogs设置任何大小:)

相关问题