xamarin.forms 在工具栏中添加开关 [英] xamarin.forms add switch in toolbar

查看:50
本文介绍了xamarin.forms 在工具栏中添加开关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在工具栏上添加开关?

Is it possible to add a switch on the toolbar?

<ContentPage.ToolbarItems>
    <ToolbarItem>
        <Switch x:Name="Switch1" IsToggled="True" Margin="5,0,0,0"/>
    </ToolbarItem>    
</ContentPage.ToolbarItems>

有人有什么想法吗?

谢谢!

推荐答案

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:TitleViewSample"
             x:Class="TitleViewSample.MainPage">

    <NavigationPage.TitleView>
             <Switch x:Name="Switch1" IsToggled="True" Margin="5,0,0,0"/>
    </NavigationPage.TitleView>

    <ContentPage.Content>    
        <StackLayout>
            <!-- Place new controls here -->
            <Label Text="Welcome to Xamarin.Forms!" 
            HorizontalOptions="Center"
            VerticalOptions="CenterAndExpand" />
        </StackLayout>
    </ContentPage.Content>

</ContentPage>

这篇关于xamarin.forms 在工具栏中添加开关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆