How to add an application bar to a user control in wp7 - windows-phone-7

I have built a wizard style user control that lets you add stackpanel based pages and flick between them.
I would like to add an application bar as part of the user control with next and previous buttons that enable/disable based on page displayed etc.
Application bar appears to be an attached property of PhoneApplicationPage. I have tried referencing Microsoft.Phone.Shell but get invalid type.
Any ideas how I can add it to my user control?

Application bar is such a pain in the a**. This control is not a Silverlight one but a native one. Maybe you can be more lucky with this solution:
http://blog.humann.info/post/2010/08/27/How-to-have-binding-on-the-ApplicationBar.aspx

The ApplicationBar is a service that is provided by the operating system, i.e. not part of the Framework, and can only be used at the page-level, not in your UserControl. In addition, the ApplicationBar does not support regular bindings as you've seen. As mentioned above there are a number of solutions that provide workarounds for this problem.
Alternatively, you could use the ApplicationBarButtonCommand and ApplicationBarButtonNavigation behaviors from the Silverlight Windows Phone Toolkit. It's a simple enough task to create your ApplicationBarMenuCommand if you need one.

Related

Windows Phone - Loading/Saving panel

I often need loading panel, which shows an indeterminate progressbar and a textblock in fullscreen mode. I do this with a Grid and just set the visibilty so visible. Instead of copy source code from page to page, I want to re-use it as a control. Is there already an existing control I can use?
Create your own usercontrol is the best way if you want to reuse the control. There are a lot of guides on Google, search for "custom user control silverlight" or something similar.

How to create a tab control where every tab item is connected with a different listbox

How can we create a tab control where every tab item is connected with a different listbox, so the view are different for every tab? I want to know what is the best solution for this, I tried two approaches:
All logic of tab activity is built in one class that is
mainPage.xaml.cs
For every tab I create a new class and call it when a tab event
fires
What is the best solution and if answer is second then what is procedure to add different view but the all the tab appear every time?
Or provide a link where I can get a full example of tab control usage in Windows Phone 7.
Windows Phone does not provide a TabControl implementation, however, it does provide the unique Pivot control, which provides the same level of functionality and is documented on MSDN. You might also find this post by Jeff Wilcox useful: http://www.jeff.wilcox.name/2010/08/looking-ahead-at-panorama-and-pivot/
Here is an article I wrote on how to use the TabControl in a Windows Phone Silverlight application. It does not really abide the current UI guidelines, but it works. All you need to do is use ListBox controls as proper child elements.

WP7 - Text Button on the Application Bar

On Windows Phone 7, go to Settings, email & accounts, add an account, the Windows Live (or any other). Note at the bottom there is the gray panel with a rectangular [sign in] button. Click in the email address field, and the on screen keyboard pops up ABOVE the gray panel. Rotate the phone, and the gray panel does not rotate, although the page does. That gray panel is the Application Bar, is it not?
I only find docs for adding an icon-based round button (and menu items). How do we put a rectangular textual button on the Application Bar?
Adding buttons in the Application Bar is not supported for third party developers. The Application Bar itself is not a Silverlight control; it's a native one. Only OEMs, certain partners and MS have access to the native SDK, so you won't be able to template the Application Bar to have buttons. Of course, you could create your own Application Bar that mimics the real one, but I don't recommend that approach as it would be very tricky to get it exactly right and be consistent between apps.
Yes, that's the application bar. Well, it's the non Silverlight version of it. (The built in apps are not built with Silverlight.)
Unfortuanately it is not possible to use text buttons on the application bar. It's only possible to use buttons with images.
Yes it would be nice/useful in a number of situations but it's just not possible with the current SDK (even Mango). I keep hoping it'll be there in a future version...
The applications that come with the phone are not restricted to using developer APIs and the one you mention likely uses C++ and / or restricted APIs. As a third-party developer your only option is to stick with icons on the application bar.
You can always create a Panel colored like the application bar, aligned along the bottom of the screen and display buttons or whatever other UI element you want to.

Is it possible to add textBlock to windows phone 7 Applicationbar

In my ebook app, I wanted to show current page number as as textBlock on Application bar.
I couldn't find a way to add textBlock to the application bar.
Unfortunately you cannot modify the application bar itself. To build something like you'd need to create your own application bar style control.
I'm not entirely sure if this is a good thing because it would be inconsistent with the rest of the phone and could possibly violate some style guides.
You can also check this: Bindable Application Bar Extensions for Windows Phone 7

Custom Painted Controls

We need to automate GUI testing of an application developed in Win32 API. Developer's have created this application by custom painted controls. They have controls which look like Grid, Buttons etc., but they are not basic Windows controls.
What is custom painted controls? and how we can test these controls?
Test it just like any other UI: Not at all. Move all code out of the callbacks into the application layer where your unit tests can execute them just like any other method.
Rationale: There is little point in testing whether "button.activate()" works; you want to know whether the your code behind the button callback works.
If you need to know whether the correct dialogs, etc., are opened, see my blog: Testing the Impossible: User Dialogs
Have the developers added support for accessibility using IAccessible? If they have, you can use active accessibility to navigate through the controls and test them that way.
If they haven't, open a bug that says that their controls can't be use by disabled people (who need a screen reader or other accessibility aid).
Once they fix that bug, you can use whatever mechanism they added to their controls to allow them to be used by screen readers and other accessibility aids to test their UI.

Resources