如何使用 xamarin 中的选择器或其他方式在模型中多选项目?

问题描述 投票:0回答:1

xaml.cs 页面:

public partial class TalimatGorevEkle : ContentPage
    {
        TalimatGorevModelmobil Model;
        
        public TalimatGorevEkle() { 

            InitializeComponent();
            var kullanicilist = Methodlar.GorevliListeGetir(Sabitler.Token);
           
            
            KullaniciSec.ItemsSource = kullanicilist.GorevliListe;  //picker'da listelenecek kişiler

            
        }
    }

.xaml文件:

<?xml version="1.0" encoding="UTF-8" ?>
<ContentPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="OzelKalem.Views.ListeContentViews.TalimatGorevEkle">
    <ContentPage.Content>
        <ScrollView>
            <StackLayout>
              
               <Grid>
                   <StackLayout  Grid.Row="0" Padding="8">
                       <Label Text="Görev Başlığı:" TextColor="#FF7F24" FontSize="14"></Label>
                       <Entry x:Name="talimatAdi" Placeholder="Görev Başlığı Giriniz" HeightRequest="60" ></Entry>
                       <Label Text="Görev Adı:" TextColor="#FF7F24" FontSize="14" ></Label>
                       <Entry x:Name="talimatGörevAdi" Placeholder="Görev Adı Giriniz" HeightRequest="60" ></Entry>
                       <Label Text= "Görevin Son Tarihini Seçiniz:" TextColor="#FF7F24" FontSize="14"></Label>
                       <DatePicker Format="dd-MM-yyyy HH:mm" x:Name="gorevSonTarih" TextColor="Black" ></DatePicker>
                       <Picker x:Name="KullaniciSec" Title="Kullanıcı seçiniz." ItemsSource="{Binding GorevliListeModel}" ItemDisplayBinding="{Binding GorevliKullaniciAdi}"></Picker>
                       <Button x:Name="SaveCourseButton" Clicked="GorevEkle" Command="{Binding}" Text="Kaydet" BackgroundColor="LightGray" TextColor="#FF7F24" Margin="3" />
                       
                   </StackLayout>


               </Grid>
            </StackLayout>
        </ScrollView>
    </ContentPage.Content>
</ContentPage>

我在 xamarin 中有一个列表,我将其显示在选择器中。但我希望它是多重可选的。我该如何为它写作? 我应该如何选择它作为复选框或选择器?

c# xamarin checkbox multi-select picker
1个回答
0
投票

是的,对于多选项目,您可以使用 CollectionView的多选来实现这个

你可以在这里查看官方样本

当然你也可以在

CheckBox
的每一项加上
ListView
来达到这个目的

这里有一个类似的线程,你可以在这里查看:How to create select all check box in xamarin form.

© www.soinside.com 2019 - 2024. All rights reserved.