将数据从Page传递到Page Xamarin表单

时间:2018-03-14 11:43:49

标签: xamarin.forms

这是我的页面

        List<User> list = new ArrayList<>();
        list.add(new User("User","20"));
        list.add(new User("Some User","20"));
        List<User> list1 = new ArrayList<>();

        list1.add(new User("User","20"));
        list1.add(new User("Some User","20"));

        List<User> storeList = new ArrayList<>();


        for (User user: list){
            for (User user1:list1){
                if (user.getName().equals(user1.getName()) && user.getAge().equals(user1.getAge()))
                    storeList.add(user);
            }
        }

        boolean check = !storeList.isEmpty();
       //OR


        check = storeList.size() == list.size();

        System.out.println(check);

档案.cs

<?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="VMO.APP.Maga.ListaLiberaInsertPage"
             Title="Lista libera - Inserimento">
    <ContentPage.Content>
        <StackLayout Orientation="Vertical">
            <StackLayout Orientation="Horizontal">
                <Label Text="Cliente: "></Label>
                <Button Text="Seleziona&#10;Cliente" x:Name="ClienteSelect"></Button>
            </StackLayout>
            <StackLayout Orientation="Horizontal">
                <Label Text="Magazzino: "></Label>
                <Button Text="Seleziona&#10;Magazzino" x:Name="MagazzinoSelect"></Button>
            </StackLayout>
            <StackLayout Orientation="Horizontal">
                <Label Text="Codice: "></Label>
                <Entry x:Name="BarcodeFilterEntry" Placeholder="Digitare il Barcode" />
            </StackLayout>
            <StackLayout Orientation="Horizontal">
                <Label Text="Descrizione: " x:Name="DescArticolo"></Label>
                <Entry x:Name="Barcode" ></Entry>
            </StackLayout>
            <StackLayout Orientation="Horizontal">
                <Label Text="Quantità: "></Label>
                <Entry x:Name="QuantitaEntry" ></Entry>
            </StackLayout>
            <StackLayout Orientation="Horizontal">
                <Button Text="Aggiungi" x:Name="AggiungiButton" Clicked="OnAddClicked"></Button>
            </StackLayout>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

这是从页面A调用的两个页面中的一个...我应该找到一种方法从A中调用B选择一个元素,然后返回到A并更改按钮的文本和同样的事情来做它从A到C ......只有当我点击C时,更改B的按钮才会返回原始文本...我不使用MVVM

public partial class ListaLiberaInsertPage : ContentPage
    {

        public ListaLiberaInsertPage (Session session)
        {
            InitializeComponent ();
            OnPageLoad(session);
        }

        public ListaLiberaInsertPage(Session session, BpId cliente)
        {
            InitializeComponent();
            OnPageLoad(session);
            ClienteSelect.Text = string.Format("{0} ({1})",cliente.CardName, cliente.CardCode);
        }

        public ListaLiberaInsertPage(Session session, Magazzino magazzino)
        {
            InitializeComponent();
            OnPageLoad(session);
            MagazzinoSelect.Text = magazzino.WarehouseName;
        }

        protected override void OnAppearing()
        {
            BarcodeFilterEntry.Focus();
        }

        void OnPageLoad(Session session)
        {

            BarcodeFilterEntry.Completed += (sender, e) =>
            {
                OnSubmitClickedAsync(sender, e, session);
            };

            ClienteSelect.Clicked += (sender, e) =>
            {
                OnOpenClienteSelectClicked(sender, e, session);
            };

            MagazzinoSelect.Clicked += (sender, e) =>
            {
                OnOpenMagazzinoSelectClicked(sender, e, session);
            };

        }

        private async void OnOpenClienteSelectClicked(object sender, EventArgs e, Session session)
        {
            await Navigation.PushAsync(new ClientiListPage(session));
        }

        private async void OnOpenMagazzinoSelectClicked(object sender, EventArgs e, Session session)
        {
            await Navigation.PushAsync(new MagaListPage(session));
        }

    }

0 个答案:

没有答案