As you can see, the code above has two buttons, refresh and search and one menu item, about; they have the "IconUri" property that sets the icon source for them and also a "Text" property that contains a small text that is displayed below the icon. Menu items do not have IconUri since they do not contain images.
I have also added the click event on each button and menu item. When you switch your app into landscape mode the application bar paints itself in the side of the screen and has some built-in animations for that.
You can also set the opacity of the Application Bar to less than 1 so that it gives a different look and the background text is visible. View All. Windows Phone : Application Bar.
In the page constructor, after the call of InitializeComponent ; you have to initialize a new ApplicationBar object. Now you can begin to set all the Application Bar properties you need. In this example all the properties of the Application Bar will be set.
You can also choose to set only the ones you need. The code is the same both for C and VB:. After this you can add buttons or menu items. At least one button is required by the Application Bar, menus are optional. Begin with adding a Button. We have to create an ApplicationBarIconButton object first, and then set its icon and label. The icon image of the button must be placed in the Image folder or sub-folder of the Application project folder. If you don't have this folder you have to create it.
Now back to the code. You can add more buttons. To add a menu you have to create an 'ApplicationBar'MenuItem and set its text. Now our Application Bar is ready! Time to add icon buttons and menu items expose click events handlers. For each button and menu item we added in the previous part we have to identify the event which will be called when users click on it. For the menu:. And then we have to add the call to the specific function for the click input:.
Now your application bar is complete. You can gladly ignore the error. In the code of my ViewModel I created a public boolean property that is set to false when the button should be disabled in the view.
In theory this should work. But sadly, it does not. So setting the CanExecute value to false Show simplistically here should disable the button. Doing this does not work either. This might be a bug in the control. But for now it is a workaround.
Create a new Windows Phone application and select Windows Phone 8. Paste the icons into the Assets folder of your project. Open MainPage. Show "Call Button Clicked! Show "Email Button Clicked! Show "Search Button Clicked! Now build and run the application. Preview 2.
0コメント