locked
ToolbarItems twice on the page RRS feed

  • Question

  • User295945 posted

    I'm trying to solve some problems with two Master-Detail tabs. So my question, why are the ToolbarItems (Cancel/Save) twice on the page?

    Monday, April 27, 2020 10:01 AM

Answers

  • User365353 posted

    Change

    async void AddItem_Clicked(object sender, EventArgs e)
    {
        await Navigation.PushAsync(new NavigationPage(new NewItemPage()));
    }
    

    to

    async void AddItem_Clicked(object sender, EventArgs e)
    {
        await Navigation.PushAsync(new NewItemPage());
    }
    

    Do you use Master Detail or Shell?

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, April 28, 2020 4:15 PM

All replies

  • User42522 posted

    @DenisMtfl First it appears you are working with TabbedPage and not Master-Detail page.

    Second, show us the code how and where you are declaring the ToolbarItems and also how you are calling the NewItemPage?

    Monday, April 27, 2020 1:05 PM
  • User365353 posted

    How did you navigated to this page?

    Monday, April 27, 2020 7:30 PM
  • User382871 posted

    Did you add the MasterDetailPage into navigation stack? If so, please remove that. ``` public App() { InitializeComponent();

    //MainPage = new NavigationPage(new MainPage());
    MainPage = new MainPage();
    

    } To display the navigation bar, making a `NavigationPage` as the **Detail** page will be fine. ```

    Tuesday, April 28, 2020 1:44 AM
  • User295945 posted

    @Jarvan thats not the problem.

    Here is some of my code:

    TabbedPage1.xaml:

        <NavigationPage Title="Eins">
            <x:Arguments>
                <views:ItemsPage />
            </x:Arguments>
        </NavigationPage>
        <NavigationPage Title="Zwei">
            <x:Arguments>
                <views:ItemsPage />
            </x:Arguments>
        </NavigationPage>
    

    ItemsPage.xaml:

    <Button Grid.Row="1" Grid.ColumnSpan="2" Text="Add" Clicked="AddItem_Clicked" />

    ItemsPage.xaml.cs:

    async void AddItem_Clicked(object sender, EventArgs e) {
    await Navigation.PushAsync(new NavigationPage(new NewItemPage())); }

    NewItemPage.xaml

    <ContentPage.ToolbarItems>
        <ToolbarItem Text="Cancel" Clicked="Cancel_Clicked" />
        <ToolbarItem Text="Save" Clicked="Save_Clicked" />
    </ContentPage.ToolbarItems>
    
    <ContentPage.Content>
        <StackLayout Spacing="20" Padding="15">
            <Label Text="Text" FontSize="Medium" />
            <Entry Text="{Binding Item.Text}" d:Text="Item name" FontSize="Small" />
            <Label Text="Description" FontSize="Medium" />
            <Editor Text="{Binding Item.Description}" d:Text="Item description" FontSize="Small" Margin="0" />
        </StackLayout>
    </ContentPage.Content>
    

    Tuesday, April 28, 2020 8:31 AM
  • User365353 posted

    Change

    async void AddItem_Clicked(object sender, EventArgs e)
    {
        await Navigation.PushAsync(new NavigationPage(new NewItemPage()));
    }
    

    to

    async void AddItem_Clicked(object sender, EventArgs e)
    {
        await Navigation.PushAsync(new NewItemPage());
    }
    

    Do you use Master Detail or Shell?

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, April 28, 2020 4:15 PM
  • User295945 posted

    Thanks @igorkr_10 but is it possible to put the ToolbarItems underneath the Tab-titles? Now it is shown above, its very discusting.

    Tuesday, April 28, 2020 8:08 PM
  • User365353 posted

    @DenisMtfl said: Thanks @igorkr_10 but is it possible to put the ToolbarItems underneath the Tab-titles? Now it is shown above, its very discusting.

    Can you show what you have now and what the result you need to achieve?

    Wednesday, April 29, 2020 8:18 AM