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。但这不能帮助您,因为上面使用的完整逻辑存在缺陷。