c# - 设置 RowDefinition 可以采用 Xamarin 应用程序的最大高度
问题描述
我试图让第二行根据内容动态缩放,但它应该只增长到一定高度。与聊天应用程序所做的类似,可扩展编辑器会根据其包含的文本进行扩展。我的问题是,如果文本真的足够高,它可能会使第一行不可见。
如何设置第二行的最大高度,以免第一行被遮挡?
内容页面.cs
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:renderer="clr-namespace:Project.renderers"
x:Class="Project.MainPage">
<Grid VerticalOptions="FillAndExpand">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ListView VerticalOptions="Fill" Grid.Row="0"/>
<StackLayout Orientation="Horizontal"
VerticalOptions="EndAndExpand"
BackgroundColor="Green"
HorizontalOptions="Fill"
Grid.Row="1">
<renderer:ExpandableEditor VerticalOptions="FillAndExpand"
HorizontalOptions="Center"
MaxLength="3000"
AutoSize="TextChanges"
TextColor="Black"/>
</StackLayout>
</Grid>
</ContentPage>
ExpandableEditor.cs
public class ExpandableEditor : Editor
{
public ExpandableEditor()
{
TextChanged += OnTextChanged;
}
~ExpandableEditor()
{
TextChanged -= OnTextChanged;
}
private void OnTextChanged(object sender, TextChangedEventArgs e)
{
InvalidateMeasure();
}
}
解决方案
推荐阅读
- angular - TypeError:无法读取未定义 Angular 的属性“indexOf”
- algorithm - 从数组中查找元素,使得没有两个相邻且总和最大
- vba - 根据另一个单元格中的值自动填充 x 行的代码
- java - “InputMismatchException”错误,计算文件中的行数
- powershell - 如何在不使用 SMB 共享的情况下使用 Powershell 远程列出文件(仅限 winRM 端口)?
- c++ - C ++ 11类中放置枚举类的重载运算符
- keras - 将输入与 keras 中的常量向量连接起来。如何定义batch_size
- azure-devops - 将 PFX 添加到 VSTS 上的强名称 CSP
- office-js - 在 Windows Server 上加载 Word 加载项
- docker - 詹金斯:从奴隶推送到 ECR