xaml - 按钮 Xamarin Forms 中的堆栈布局

标签 xaml xamarin xamarin.forms

是否可以将堆栈布局放入按钮中?

      <StackLayout HorizontalOptions="Start" Orientation="Horizontal">
             <Label Text="s" FontFamily="icon-font" FontSize="16" FontAttributes="Bold" TextColor="{StaticResource orangeColor}"></Label>
             <Label Text="Test" FontSize="16" FontAttributes="Bold" />
      </StackLayout>

我有一个图标字体文件。我想渲染按钮内容内的图标和普通文本。可以在 Xamarin Forms 中执行吗?

最佳答案

您可以添加TapGestureRecognizer添加到您的标签,以便您可以像按钮一样“单击”它们

var tapGestureRecognizer = new TapGestureRecognizer();
tapGestureRecognizer.Tapped += (s, e) => {
   // handle the tap
};
myLabel.GestureRecognizers.Add(tapGestureRecognizer);

关于xaml - 按钮 Xamarin Forms 中的堆栈布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42588710/

相关文章:

c# - 如何在 xamarin android 项目上集成 webrtc android native 库?

c# - 如何使用 MVVM 从代码中使用 "text.changed"控件(在 Xamarin.Forms 中)

c# - Xamarin Studio/VS for Mac Storyboard未打开

xamarin - 从 ControlTemplate 绑定(bind)到 ContentPage 标题

c# - CollectionView : Filter does not work when binding to e. g。列表框

c# - 移动 MainWindow.xaml

c# - Xamarin 网格和 StackLayout

xamarin - DependencyService.Get<>() 不起作用

wpf - 样式中的代码可重用性

wpf - 绑定(bind)语法的 StringFormat 部分中的 {} 括号有何含义?