Matthew
Matthew

Reputation: 4056

how to set applicationbar opacity from code behind

I have been attempting to set the applicationbar on my MainPage in the code behind based on a slider bar that the user may control at will. I have a lot of information in my applicationbar so I created it in xaml, except for the opacity which should change depending on the values of the slider. I am unsure though of how to access the MainPage applicationbar opacity from the codebehind?

Upvotes: 2

Views: 1318

Answers (2)

Matthew
Matthew

Reputation: 4056

To change the opacity value of a currently existing ApplicationBar, use the following

(ApplicationBar as ApplicationBar).Opacity = num;

where num is your opacity of preference!

Upvotes: 1

coder
coder

Reputation: 13248

Try this:

 ApplicationBar = new ApplicationBar();
 ApplicationBar.Opacity=0.5;
 ApplicationBar.IsMenuEnabled = true;
 ApplicationBarIconButton button1 = new ApplicationBarIconButton(new Uri("/Images/appbar.feature.search.rest.png", UriKind.Relative));
 button1.Text = "Search";
 ApplicationBar.Buttons.Add(button1);
 ApplicationBarMenuItem menuItem1 = new ApplicationBarMenuItem("MenuItem 1");
 ApplicationBar.MenuItems.Add(menuItem1);

Upvotes: 4

Related Questions