Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xaml 如何在xamarin表单的列表视图中仅添加一次按钮_Xaml_Xamarin_Xamarin.forms - Fatal编程技术网

Xaml 如何在xamarin表单的列表视图中仅添加一次按钮

Xaml 如何在xamarin表单的列表视图中仅添加一次按钮,xaml,xamarin,xamarin.forms,Xaml,Xamarin,Xamarin.forms,使用此代码 x:Class=“适合计划。时间线页面” Title=“时间线” BackgroundColor=“{DynamicSource MainWrapperBackgroundColor} 但是如果我想在列表视图的末尾只显示一次订单按钮,如何实现呢 我尝试过,但没有成功: 它在末尾显示了按钮,但列表为空。ListView提供了HeaderTemplate和FooterTemplate。您应该将按钮放在FooterTemplate中,如下所示: <ListView I

使用此代码

x:Class=“适合计划。时间线页面”
Title=“时间线”
BackgroundColor=“{DynamicSource MainWrapperBackgroundColor}

但是如果我想在列表视图的末尾只显示一次订单按钮,如何实现呢

我尝试过,但没有成功:



它在末尾显示了按钮,但列表为空。ListView提供了
HeaderTemplate
FooterTemplate
。您应该将按钮放在
FooterTemplate
中,如下所示:

<ListView ItemsSource="{ Binding TimelineList }" SeparatorVisibility="None" BackgroundColor="{ DynamicResource BasePageColor }" HasUnevenRows="true">
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <ViewCell.View>
                      .................
                </ViewCell.View>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
    <ListView.FooterTemplate>
        <DataTemplate>
            <ContentView>
              //Put your button here
            </ContentView>  
         </DataTemplate>  
    </ListView.FooterTemplate>
</ListView>

.................
//把你的按钮放在这里
  
  

从上一个答案开始,您可以将按钮放在页脚中,或者如果您想将按钮保留在单元格模板中,然后用IsVisible=您的自定义转换器将按钮包装起来,这将检查
如果(myIndex==TotalistCount)
然后,按钮将仅显示列表中最后一项。

尼克,但是,这可能解决了问题,但不是实现这一点的好方法。这会为每个ListView项创建一个按钮实例。使用
解决了我的问题
<ContentPage.Content>


    <ListView
        ItemsSource="{ Binding TimelineList }" 
        SeparatorVisibility="None"
        BackgroundColor="{ DynamicResource BasePageColor }"
        HasUnevenRows="true">
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                   <ViewCell.View>
                       <StackLayout>
                            <StackLayout>
                                <Grid x:Name="GridTasks">
                                    <local:TimelineItemTemplate  
                                    Padding="{ DynamicResource MainWrapperPadding }"/>
                                </Grid>
                            </StackLayout>
                            <StackLayout>
                           </StackLayout>
                        </StackLayout>
                    </ViewCell.View>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>
</ContentPage.Content>
<artina:Button   
    Clicked="OnNextButtonTapped" 
    Style="{DynamicResource PrimaryActionButtonStyle}" 
    Text="Order" 
    VerticalOptions="EndAndExpand"
    WidthRequest="{ artina:OnOrientationDouble
                            LandscapeTablet=600 }"
    HorizontalOptions="{ artina:OnOrientationLayoutOptions
                            PortraitPhone=Fill,
                            LandscapePhone=Fill,
                             PortraitTablet=Fill,
                            LandscapeTablet=Center }"/>
<ListView ItemsSource="{ Binding TimelineList }" SeparatorVisibility="None" BackgroundColor="{ DynamicResource BasePageColor }" HasUnevenRows="true">
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <ViewCell.View>
                      .................
                </ViewCell.View>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
    <ListView.FooterTemplate>
        <DataTemplate>
            <ContentView>
              //Put your button here
            </ContentView>  
         </DataTemplate>  
    </ListView.FooterTemplate>
</ListView>