Xamarin 如何在旋转木马视图中设置listview所选项目为空

Xamarin 如何在旋转木马视图中设置listview所选项目为空,xamarin,xamarin.forms,Xamarin,Xamarin.forms,我在旋转视图中有设置列表视图,但如何存档设置列表视图所选项目为空,现在当我点击列表视图项目中的任何项目旋转视图时,它会显示默认颜色,但我们需要删除该颜色。请提出任何意见。提前谢谢 示例代码: <cv:CarouselView VerticalOptions = "FillAndExpand" HorizontalOptions = "FillAndExpand" Position = "{Binding DishCategory}" ItemSelected = "OnSwipeDish

我在旋转视图中有设置列表视图,但如何存档设置列表视图所选项目为空,现在当我点击列表视图项目中的任何项目旋转视图时,它会显示默认颜色,但我们需要删除该颜色。请提出任何意见。提前谢谢

示例代码:

 <cv:CarouselView VerticalOptions = "FillAndExpand" HorizontalOptions = "FillAndExpand" Position = "{Binding DishCategory}" ItemSelected = "OnSwipeDishesHandler" ItemsSource = "{Binding RestaurantDishesList}" x:Name = "RestaurantDishesList">
                    <cv:CarouselView.HeightRequest>
                        <OnIdiom x:TypeArguments ="x:Double" Phone ="230" Tablet ="630"/>
                    </cv:CarouselView.HeightRequest>                  
                    <cv:CarouselView.ItemTemplate>
                        <DataTemplate>
                            <StackLayout Padding = "10,5,10,5" Orientation = "Vertical">
                                <ListView x:Name="RestaurantMenuListView" BackgroundColor="Transparent" ItemsSource="{Binding CategoryWiseDishes}" HasUnevenRows="true" SeparatorColor="#eeeeee">
                                    <ListView.ItemTemplate>
                                        <DataTemplate>
                                            <ViewCell>
                                                <StackLayout Padding="7">
                                                    <Grid Padding="2">
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition Width="*"/>
                                                            <ColumnDefinition Width="Auto"/>
                                                        </Grid.ColumnDefinitions>
                                                        <StackLayout Grid.Column="0" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                                                            <StackLayout.GestureRecognizers>
                                                                <TapGestureRecognizer Tapped="OnMenuItemSelected"/>
                                                            </StackLayout.GestureRecognizers>
                                                            <Label Text="{Binding Name}" TextColor="Black">
                                                                <Label.FontSize>
                                                                    <OnIdiom x:TypeArguments ="x:Double" Phone ="15" Tablet ="20"/>
                                                                </Label.FontSize>
                                                            </Label>
                                                            <Label Text="{Binding Description}" TextColor="#323232">
                                                                <Label.FontSize>
                                                                    <OnIdiom x:TypeArguments ="x:Double" Phone ="11" Tablet ="16"/>
                                                                </Label.FontSize>
                                                            </Label>
                                                            <StackLayout Orientation="Horizontal">
                                                                <Label Text="£" TextColor="Black">
                                                                    <Label.FontSize>
                                                                        <OnIdiom x:TypeArguments ="x:Double" Phone ="14" Tablet ="19"/>
                                                                    </Label.FontSize>
                                                                </Label>
                                                                <Label Text="{Binding Cost}" TextColor="Black">
                                                                    <Label.FontSize>
                                                                        <OnIdiom x:TypeArguments ="x:Double" Phone ="14" Tablet ="19"/>
                                                                    </Label.FontSize>
                                                                </Label>
                                                            </StackLayout>
                                                        </StackLayout>
                                                        <StackLayout Grid.Column="1" Orientation="Horizontal" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                                                            <Image Source="minus.png">
                                                                <Image.WidthRequest>
                                                                    <OnIdiom x:TypeArguments ="x:Double" Phone ="25" Tablet ="35"/>
                                                                </Image.WidthRequest>
                                                                <Image.HeightRequest>
                                                                    <OnIdiom x:TypeArguments ="x:Double" Phone ="25" Tablet ="35"/>
                                                                </Image.HeightRequest>
                                                                <Image.GestureRecognizers>
                                                                    <TapGestureRecognizer Tapped="RemoveItemBtnClicked"/>
                                                                </Image.GestureRecognizers>
                                                            </Image>
                                                          <Label Text="{Binding TotalQuantity}" HorizontalOptions="Center" VerticalOptions="Center" TextColor="Black">
                                                            <Label.FontSize>
                                                              <OnIdiom x:TypeArguments="x:Double">
                                                                <OnIdiom.Phone>
                                                                  <OnPlatform x:TypeArguments="x:Double" iOS="13" Android="13" WinPhone="13" />
                                                                </OnIdiom.Phone>
                                                                <OnIdiom.Tablet>
                                                                  <OnPlatform x:TypeArguments="x:Double" iOS="15" Android="15" WinPhone="15" />
                                                                </OnIdiom.Tablet>
                                                              </OnIdiom>
                                                            </Label.FontSize>
                                                          </Label>
                                                            <Image Source="add.png">
                                                                <Image.WidthRequest>
                                                                    <OnIdiom x:TypeArguments ="x:Double" Phone ="25" Tablet ="35"/>
                                                                </Image.WidthRequest>
                                                                <Image.HeightRequest>
                                                                    <OnIdiom x:TypeArguments ="x:Double" Phone ="25" Tablet ="35"/>
                                                                </Image.HeightRequest>
                                                                <Image.GestureRecognizers>
                                                                    <TapGestureRecognizer Tapped="AddItemBtnClicked"/>
                                                                </Image.GestureRecognizers>
                                                            </Image>
                                                        </StackLayout>
                                                    </Grid>
                                                </StackLayout>
                                            </ViewCell>
                                        </DataTemplate>
                                    </ListView.ItemTemplate>
                                </ListView>
                            </StackLayout>
                        </DataTemplate>
                    </cv:CarouselView.ItemTemplate>
                </cv:CarouselView>    
当我点击总量标签时,它会在第行显示默认颜色。需要删除该颜色。

在xaml文件中

<ListView x:Name="RestaurantMenuListView" BackgroundColor="Transparent" ItemsSource="{Binding CategoryWiseDishes}" HasUnevenRows="true" SeparatorColor="#eeeeee" ItemTapped="OnItemTapped">

如果您使用MVVM而不是代码隐藏,请访问本教程

您应该使用两个绑定或转到本教程


到目前为止你试过什么?什么不起作用?谢谢你花时间回答我的问题。我已尝试将列表视图中的选定事件项设置为null,但在xaml.cs文件中未检测到列表视图中的旋转木马视图。那么我如何设置列表视图内旋转木马视图的选定事件为null请显示您的xamlHi yuri,我已用示例代码更新了我的问题。你能看一下吗,那太好了,普拉文。
public void OnItemTapped(object sender, ItemTappedEventArgs e)
    {
        ((ListView)sender).SelectedItem = null;
    }
public ICommand SelectionCommand => new Command(ItemSelected);

        private async void ItemSelected()

        {

            if (Selection != null)

            {

                var persondetaildata = Selection.Name;

                await Shell.Current.GoToAsync($"//DetailPage?persondetaildata={persondetaildata}");

                Selection = null;

            }

        }