【问题标题】:Stack layout in a button Xamarin Forms按钮中的堆栈布局 Xamarin Forms
【发布时间】:2017-03-03 21:26:41
【问题描述】:

是否可以在按钮中放置堆栈布局?

      <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 中执行?

【问题讨论】:

  • 不,但是你可以让你的 StackLayout 看起来像一个按钮。

标签: xaml xamarin xamarin.forms


【解决方案1】:

您可以将TapGestureRecognizer 添加到您的标签中,这样您就可以像按钮一样“点击”它们

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多