微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

您可以用自定义视图包围内容吗?

如何解决您可以用自定义视图包围内容吗?

我在页面中有一堆代码,希望可以在多个页面上重复使用

    <StackLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
        <swipeview x:Name="Mainswipeview" BackgroundColor="Transparent"
                   Swipestarted="Swipestarted" SwipeEnded="SwipeEnded" VerticalOptions="FillAndExpand">
            <swipeview.LeftItems>
            </swipeview.LeftItems>
            <Grid x:Name="swipeContent">
  


                Where I want the rest of the content to be 
                (This means this would surround the content,similar to <ContentPresenter/> in a ControlTemplate)
  


            </Grid>
        </swipeview>
        <StackLayout HeightRequest="50" BackgroundColor="Red">
            <Label> Where the Augnito Button will be </Label>
        </StackLayout>
    </StackLayout>

我想将其放入可重用的组件中,以便可以在其他页面中使用它,如下所示:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                 . 
                 .
                 .
                 .>
    <MyReusableComponent>
         <StackLayout>

                 This is where the regular contents of a page would go

        </StackLayout>
    </MyReusableComponent>
</ContentPage>

我认为我不能使用ControlTemplate,因为我的自定义视图在xaml.cs文件中的后面都有代码以使其正常工作,所以还有另一种方法吗?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。