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

问题描述

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

    <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 (将#修改为@)