xaml - 按钮内的 Xamarin.Forms TextBlock。文本的自定义换行
问题描述
Xamarin.Forms XAML。按钮上的文本错误地移动到新行。我需要这样做,以便我可以配置包装。试图这样做:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="SaleAgent.MainPage"
Title = "Торговый агент">
<ContentPage.Resources>
<Style x:Key="buttonStyle" TargetType="{x:Type Button}">
<Setter Property="FontSize" Value="Small" />
<Setter Property="Template">
<Setter.Value>
<TextBlock></TextBlock>
</Setter.Value>
</Setter>
</Style>
</ContentPage.Resources>
<ContentPage.Content>
<Grid x:Name="mainGrid" RowSpacing="1" ColumnSpacing="1">
<Grid.RowDefinitions>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
</Grid.ColumnDefinitions>
<Button Grid.Row="1" Grid.Column="1" Grid.RowSpan="3" Style="{StaticResource buttonStyle}"/>
</Grid>
</ContentPage.Content>
</ContentPage>
但是 TextBlock 给了我错误:
XLS0414 找不到类型“TextBlock”。确认您没有丢失程序集引用并且所有引用的程序集都已构建
解决方案
您正在使用 WPF/UWP XAML。Xamarin 不支持它。在这里回答它们之间的区别超出了范围,您应该学习它。
但是要回答您的问题(这不是上面代码中的唯一问题),Xamarin 中没有 TextBlock,而是 Label。但这并不能帮助您工作,因为上面使用的完整逻辑是有缺陷的。
推荐阅读
- c# - 我正在使用 C# 上的本地数据库(附图片)一个 throw ex 函数,给了我以下代码。请协助解决错误
- html - 导航栏中的 HTML 幻灯片位置错误
- python - 如何计算熊猫中两列数据帧之间的相关性
- angular - 带括号的角度查询参数?
- python - python函数的变量地址问题
- sql - 在 JSON 中查找某个对象
- azure-devops - TF.exe git 权限登录在管道中失败但在本地正确登录
- random - 如何从一个区间中选择几个随机数?
- python - 如何在 Python 中查询复杂的嵌套 JSON 数据
- python - map() 一个带有 numpy 数组和列表作为参数的函数