M
M
MisterADK2020-08-11 16:41:10
C++ / C#
MisterADK, 2020-08-11 16:41:10

How to display the value of a variable in another xamarin page?

MainPage c# (Here I am passing an array):

[DesignTimeVisible(false)]
    public partial class MainPage : ContentPage
    {
        private MyContext context { get; }
        public MainPage()
        {
            InitializeComponent();
            context = new MyContext();
            this.BindingContext = context;

        }
       
        private async void OnNoteAddedClicked(object sender, EventArgs e)
        {
            ViewModels.Item[] valueName = context.Items;
            await Navigation.PushAsync(new ResultPage(valueName));
        }

    }

ResultPage c# (accept an array):
[XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class ResultPage : ContentPage
    {

        Item[] _Items;
        public ResultPage(Item[] Items)
        {
            _Items = Items;
            InitializeComponent();    
        }
    }

ResultPage xaml (trying to display the value of an array element):
<Button
                    Grid.Row="1"
                    Grid.Column="1"
                    BindingContext="{Binding Items[0]}" 
                    Text="{Binding Value}" />
                <Label
                    Grid.Row="1"
                    Grid.Column="2"
                    HorizontalTextAlignment="Center"
                    BindingContext="{Binding Items[1]}"
                    Text="{Binding Value}" />

The question is this: it displays emptiness, maybe someone knows what the problem is?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question