XAML 如何将.NET Maui框架放置在屏幕底部?

jtw3ybtb  于 2022-12-07  发布在  .NET
关注(0)|答案(1)|浏览(281)
<Frame BorderColor="#2f3136"
          CornerRadius="20"
          BackgroundColor="#2f212b"
          Grid.Row="0">
                
               <Editor x:Name="inputBox" 
                       Placeholder="Enter your message (2000 characters max)"
                       TextChanged="inputBox_Changed"
                       Completed="inputBox_Completed"
                       MaxLength="2000"
                       Keyboard="Chat"
                       AutoSize="TextChanges"/>
            
            </Frame>

框架位于屏幕的顶部,如何让它反其道而行之,而是位于屏幕的底部?

qvtsj1bj

qvtsj1bj1#

就像杰森说的,知道它是装在什么样的容器里会很有帮助。
从您的代码中,我们知道您应该使用Frame中的Grid。在这种情况下,我们可以将Frame设置为Grid的最后一行。
并设置网格的其他部分占据屏幕的所有剩余位置。
可以参考下面的代码:

<Grid Margin="20,35,20,20"> 
    <Grid.RowDefinitions>
        <RowDefinition Height="*" />
        <RowDefinition Height="100" />
    </Grid.RowDefinitions>

    <StackLayout BackgroundColor="Green" 
                 VerticalOptions="FillAndExpand"  
                 Grid.Row="0">
                   
    </StackLayout>
           
    <Frame BorderColor="#2f3136" 
      CornerRadius="20"
      BackgroundColor="#2f212b" 
           
      HeightRequest="100"
      Grid.Row="1"
      VerticalOptions="End" >
        <Editor x:Name="inputBox" 
                   Placeholder="Enter your message (2000 characters max)"
                   MaxLength="2000"
                   Keyboard="Chat"
                   AutoSize="TextChanges"/>

    </Frame>
</Grid>

注意事项:
1.假设有两行,我将FrameGrid.Row设置为1,并添加以下属性:

VerticalOptions="End"

2.我将第一行的高度设置为*

<Grid.RowDefinitions>
        <RowDefinition Height="*" />
        <RowDefinition Height="100" />
    </Grid.RowDefinitions>

相关问题