1

对于数据模板,我在StackLayout其中使用了标签,grid-view.

代码RendererFactory.getRenderer()不起作用;它只显示 aStackLayout里面没有任何标签。

任何帮助,将不胜感激。

4

1 回答 1

1

截至目前RendererFactory.getRenderer(),对于具有子内容的自动布局容器(例如 StackLayout/GridLayout)不起作用,请参阅此链接。仅渲染主要父级,但子级未在 UI 中渲染,但控件在转换为本机视图后可用 this._view = RendererFactory.GetRenderer(this._viewCell.View).NativeView;

尝试AbsoluteLayout相应地使用和定位控件。我曾使用XLabs Grid View Control尝试过此操作,因为他们使用 Grid View Renderer 来制作 UICollectionView(TileList) 和GridViewCell来生成从 Forms 到 Native 的 viewCell。

<controls:GridView
                    x:Name="GrdView"
                    RowSpacing="5"
                    Padding="5"
                    ColumnSpacing = "5"
                    ItemWidth ="152"
                    ItemHeight = "200"
                    ItemsSource="{Binding gridColl}"
                >
            <controls:GridView.ItemTemplate>
                <DataTemplate >
                    <ViewCell>
                        <ViewCell.View>
                         <!-- WORKING-->
                            <AbsoluteLayout BackgroundColor="Red">

                                <Image Source="{Binding image}"  
                                       AbsoluteLayout.LayoutBounds="0, 0, 0.5, 0.5"
                                        AbsoluteLayout.LayoutFlags="All"/>
                                <BoxView Color="#8080FF"
                                         AbsoluteLayout.LayoutBounds="0.33, 0, 0.25, 0.25"
                                         AbsoluteLayout.LayoutFlags="All" />
                                <Label Text="Test" BackgroundColor="Red"
                                       AbsoluteLayout.LayoutBounds="1, 1, 0.5, 0.5"
                                       AbsoluteLayout.LayoutFlags="All"/>
                            </AbsoluteLayout>

                             <!--NOT WORKING-->
                            <!--<StackLayout BackgroundColor="Blue">
                                <Image Source="{Binding image}" />
                                <Label Text="Test" BackgroundColor="Red"/>
                            </StackLayout>-->
                        </ViewCell.View>
                    </ViewCell>
                </DataTemplate>
            </controls:GridView.ItemTemplate>
        </controls:GridView>

我希望这可以帮助你...

于 2015-07-23T13:55:01.810 回答