How to change Display Alert default focus on a button? - xamarin

I am using Xamarin forms DisplayAlert. I have two buttons in it one is light blue and another is Darker blue. I guess it is focus effect causing the difference.
can I set focus as per requirement? I tried to search documentation but no luck.
DisplayAlert("Caption", "Message", "Cancel", "Send");
Cancel and send are buttons on display alert. Default focus on Cancel.I want to switch focus to Send without changing position of buttons.

I am pretty sure that Xamarin doesn't (and will not) support providing focus to a specific button using a DisplayAlert since this feature exists in iOS only. Remember that Xamarin.Forms is meant to target all platforms, and not iOS only, and introducing a "focus" variable for a single platform would thus be a no-go.
What you can do, is to swap your two buttons around as you mentioned yourself.
If that is not an option, have a look at what you can achieve using third party libraries such as Acr.UserDialogs.
If that doesn't help you either, you will probably need to write a Custom Control or use an ActionSheet instead.
Good luck.

Related

What difference does it make if I use the SearchBar control versus the Entry control to search a ListView?

Regarding Xamarin.Forms, I've been reviewing the Entry control documentation along withe the SearchBar control documentation. After reviewing the documentation for both, they appear to be similar.
What difference does it make if I use the SearchBar control versus the Entry control to search a ListView?
I think they are functionally similar but the key difference in SearchBar is that you get different visualization and keyboard at least on iOS and Android. The Enter button has a custom icon or text and there is an icon in the entry field. Images of different devices can be found here. You can also see images of SearchBar on Android here:
The Entry when rendered is just a Textbox, using this for search is possible but you will need to manually add a search button (if needed), cancel mechanism and attach yourself to the events to make the search. In the other hand using the SearchBar all this is already part of the control, out of the box for you.
If you don't need this extra functionality or you don't mind having to rewrite it you can use the Entry otherwise go with the SearchBar.

SetWindowPos API - Backward resizing?

I'm using Windows's SetWindowPos API to try to 'crop' a part of a window so a user will only be able to see the RIGHT part of it.
Problem is, I can only 'crop' it, starting from the top left corner, and I would rather cropping a different part of the window which does not 'contain' the top left part.
As seen on the image below, what i'm trying to do is reverse the 'resizing' mechanism in such way that the window will 'hide' the Label1, and only show the Button1.
It is possible that I am not using the correct API for the job, If so, i'd love to be pointed toward the right one.
You need to move your controls on the Form for that to work. The window has a position and a size, which is all the window manager cares about. What is visible inside is your application's responsibility.
Your screenshot looks very VB6-ish. Do note that newer technologies, e.g. Windows Forms or WPF offer better support for what you are trying to do here.
If you have a window handle for the control, then you can place it outside its parent. Pass to SetWindowPos a negative value for the X coordinate.
Of course, the fact that the control cannot be seen does not mean it cannot be interacted with. The user can reach it with the keyboard if it accepts focus. So perhaps a better idea would be to hide and/or disable it. Use ShowWindow and EnableWindow to do that.
Then again, it's quite plausible that you won't be able to get a window handle. Many frameworks use controls that are not windowed. To interact with them you would need to use an automation framework such as UI Automation. Only you can know whether or not the target application supports automation.

Manually Setting the color of the WP7 System Tray

I have read the UI Design Guidelines for WP7 development and am actually a fan of Metro (to a point). However, an app I am developing is requiring custom theming regardless of the user's theme settings.
In general, I just manually set each element that I want to be sure uses a specific color (rather than a theme resource). But I can't seem to find settings regarding the system tray (status bar).
I am okay with it showing as long as I can change it's color (failing that though, how can I hide it?). The color I need it to always be is black. Obviously when the dark theme is selected, we are good to go. But it looks terrible in the light theme to have a big white bar at the top of the app.
Hopefully this is an easy question with some easy to earn rep!
It is possible to change that color in mango. SystemTray.BackgroundColor = Colors.Orange; In my case it must be inserted in OnNavidatedTo, in constructor it disappeared after 1 second.
If you want to set this in the xaml you can do something like this:
shell:SystemTray.IsVisible="True"
shell:SystemTray.Opacity="0"
shell:SystemTray.ForegroundColor="Black"
I am not aware of a way to change the theme of the system tray (or status bar). You can hide it using the SystemTray.IsVisible property.
Note that I've had trouble trying to set that property within the page constructor (I think it fails when resuming after tombstoning, don't remember exactly). The solution was to place the code in the page's Loaded or OnNavigatedTo event.

How to create custom onscreen keyboards?

Im about to start creating a custom onscreen keyboard for my WP7 app. An out of the box SIP will not work since they can't be customized or built from scratch with .NET.
Ideally the keyboard would activate like a SIP. Specifically, appear when the textbox receives focus. Docking to the bottom of the screen would be nice, too.
Any ideas where I could find samples of this?
Also, do you have any recommendations or lessons learned you could share?
I think you'll be making this sample ;)
The challenge with letting textbox take focus is likely going to be the built in SIP is going to appear. ReadOnly is an option, but you'll either lose or need to find a way to retain/mimic the cursor if that visual queue is important to you.

Windows mobile controlling scroll bar with finger

I have a question about the windows mobile development.
I created a mobile form on the windows mobile 6.0 test project. But that example form slightly larger than the vertically normal pocketpc forms. I now everybody said you can press the scrollbar for accessing bottom or any location of the form.
But i need to use the finger for easy navigating form areas. This kind of iphone :)
Is it possible ? how can i make this ?
Windows Mobile 6.5 adds gesture support, that is supposed to allow such functionality for finger control. Of course, your code has to take advantage of it.
You can also write your own, which isn't difficult, but still cumbersome.
My answer could be classified as subjective. I try to now show the scroll bar when possible for just that reason. On most devices that have touch screen, you can scroll using you finger (and I'm a somewhat large guy -- 6'3" with farmer kid hands).
But if you are displaying a grid, that isn't always possible. The results can go off the screen very easily. Oh well, grab a pen and hit the scrollbar.
Other screen elements that can help: tab control. separate your controls into groups and put each group on a separate tab. I also do a lot of wizards with LARGE next and previous buttons.
But in all of this, if it is designed to be stylus free, just pray the user doesn't have to type anything using the screen soft keyboard. That just doesn't work with a finger.

Resources