Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8999731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:13:07+00:00 2026-06-16T00:13:07+00:00

I want to add BottomAppBar programatically from code-behind in C#. I got it done

  • 0

I want to add BottomAppBar programatically from code-behind in C#. I got it done like this:

1: Added a resource file that has DataTemplate which contains a Grid, a StackPanel and two buttons.

2: In my BasePage.cs (that derives from the Page class) I define a new AppBar and set it’s ContentTemplate to the Resource created in step1.

3: I set this.BottomAppBar= AppBar from step2.

Now this add the AppBar to all my pages that are derived from BasePage. This works fine.

The issue:

I cannot get the PointerPressed or any other events fired from my two elements in AppBar.

I am sure it’s something very basic I am missing. Any ideas, anyone?

Update: Sample download link added below and what I would like is when the image in the BottomAppBar (Page1 and 2)is clicked, it should take me to MainPage.

Download Sample

AppBar Code

AppBar appbar = new AppBar();
appbar.Name = "BottomBar";
DataTemplate dt = Application.Current.Resources["BottomAppBarDT"] as DataTemplate;
appbar.ContentTemplate = dt;
this.BottomAppBar = appbar;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:13:08+00:00Added an answer on June 16, 2026 at 12:13 am

    In Data Templating its always best to implement Commands instead of Event Handlers.
    What you will want to do is make sure that you create a DelegateCommand that has the same methodology as the Button Click Event you are attempting to trigger.
    The code for the DelegateCommand should be placed in the View Model that serves as the DataContext for the parent of this particular control (App Bar) or If you’re using an MVVM structure that has a Command Aggregator it should go in there.

    public class DelegateCommand : ICommand
      {
        private Action _action;
    
        public DelegateCommand(Action action)
        {
          _action = action;
        }
    
        public bool CanExecute(object parameter)
        {
          return true;
        }
    
        public event Windows.UI.Xaml.EventHandler CanExecuteChanged;
    
    
        public void Execute(object parameter)
        {
          _action();
        }
      }
    
      /// <summary>
      /// Gets a command that executes a search
      /// </summary>
      public ICommand ExecuteSearchCommand
      {
        get
        {
          return new DelegateCommand(() => ExecuteSearch());
        }
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want add some resource files (non-code text-based files) to the jar file in
I am making a Chat application . In that I want add facility like
I want add user in ActiveDirectory. I use this code private SPUser CreateUser(string strLoginName,
I want add new Feed item on entity persist and update. I write this
I want add my custom sidebar next right column all page. Please check this
I have a list of string values that I want add to a hashtable
I have problem, when I want add Node to my GUI from other Thread.
I have numbers in javascript from 01(int) to 09(int) and I want add 1(int)
I want add new user from another script and I need create password for
hi when i write css or html i found that i want add two

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.