加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

xaml – Xamarin在按钮内部形成子控件

发布时间:2020-12-13 22:44:05 所属栏目:Windows 来源:网络整理
导读:我想在我的xamarin表单应用程序中的一个按钮内放置一些子控件.我尝试了以下代码,但子控件没有显示. ButtonStackLayout Orientation="Horizontal" Image Source="updatesite.png" HeightRequest="25" WidthRequest="25"/ Label VerticalOptions="Center" Text
我想在我的xamarin表单应用程序中的一个按钮内放置一些子控件.我尝试了以下代码,但子控件没有显示.
<Button>
<StackLayout Orientation="Horizontal">
  <Image Source="updatesite.png" HeightRequest="25" WidthRequest="25"/>
  <Label VerticalOptions="Center" Text="Update Site and Settings" FontSize="16"/>
</StackLayout>
</Button>

请帮我.

您应该将所有内容包装到Grid等布局中.然后将透明按钮放在网格上.像这样.
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="25"/>
        <RowDefinition Height="25"/>
    </Grid.RowDefinitions>
    <Image Grid.Row="0" Source="updatesite.png" />
    <Label Grid.Row="1" VerticalOptions="Center" Text="Update Site and Settings" FontSize="16"/>
    <Button Grid.Row="0" Grid.RowSpan="2" x:Name="buttonDo" 
        BackgroundColor="Transparent" TextColor="Transparent"
    />
</Grid>

这个网格就像一个有孩子的按钮.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读