Picker with two selection columns with numbers in Xamarin.Forms - xaml

I need to make a picker like this in the picture below:
What you see is a TimePicker and I took it just to give you an example. I would like to have one with about 200 numbers on the left and 100 on the right (for example). How can I do it in a Xamarin.Forms PCL project?

The first problem you'll face is that the picker control you see here is a native iOS control. The Xamarin.Forms TimePicker is basically not a physical control in itself but it translates to a native control on each platform. That's why it will look different on Android and UWP devices because they provide their own picker controls, as seen in the picture below.
Now, if you're ok with the controls looking different, you could use custom renderers to modify each native control or even replace them to provide the functionality you need. I thought I'd outline the basic steps for you to get you started:
Create a new Xamarin.Forms control called CustomPicker or something.
Create custom renderers for each platform.
On iOS, you can use the UIPickerView and specify numberOfComponents, numberOfRows and the data source.
On Android, you might want to use a 3rd party control since by default, there are no scrolling picker controls like the one on iOS. WheelPicker looks promising.
On UWP, you might be able to work something out using the PickerFlyoutBase. I have limited knowledge on the platform but you should be able to find something quite easily.
As you can see, it's going to be quite an effort to get the scroll picker working on each platform.
Edit: You could also look into native embedding, which lets you embed native controls into Xamarin.Forms app's pages.
Native Embedding
Embedding native controls into Xamarin.Forms

We've developed a two-column picker for Xamarin.Forms (Android and iOS).
Sample:
https://github.com/HorusSoftwareUY/MaterialDesignControlsPlugin#materialdoublepicker
Screenshots:
Android
iOS
We added this control to MaterialDesignControls NuGet (https://www.nuget.org/packages/Plugin.MaterialDesignControls/), where you can find other interesting controls with the material design look and feel.
Contributions are welcome!

Related

Codenameone Camera Component Customizing

all!
Is there any way to build custom camera component in codename one?
I googled and got about PeerComponents, however don't know how to use it.
I just would like to use it as Label component with 2 buttons (Taking picture button and retaking picture button)
Kindly provide some small sample code for me. Best regards.
[UPDATE]
I need this because of following reason.
First of all, I need square Image taken by camera, and user should be able to know how the picture will be taken.
2 resolutions here:
First, if I have to use full screen camera, it will be better to draw or overlay square rectangle on camera view so that user can know which area will be taken.
Second, if overlaying and drawing is difficult (or should use native code for that), I need some custom components for camera area such like PeerComponent. So I would like to place it anywhere of screen area as square rectangle. Then, users won't need any overlay or drawing something on it because it is already square.
That's all what I need.
Regards.
Yes, it's certainly possible to create a component like this, and we do intend to create one at some point in the future. You can beat us to the punch.
First, you should familiarize yourself with how native interfaces work. This video is a good start:
https://www.codenameone.com/how-do-i---access-native-device-functionality-invoke-native-interfaces.html
This series of blog posts demonstrates how to wrap 3rd party SDKs into codename one on Android and iOS.
https://www.codenameone.com/blog/integrating-3rd-party-native-sdks-part-1.html
https://www.codenameone.com/blog/integrating-3rd-party-native-sdks-part-2.html
https://www.codenameone.com/blog/integrating-3rd-party-native-sdks-part-3.html
Although it doesn't include an example with PeerComponent, it is helpful for getting a grasp on the process. Adding peer components into the mix is really just a matter of returning the corresponding "View" type from a native interface. On Android, that is an android.view.View, on iOS it is a UIView, in Javascript it is an DOM element, in UWP it is a FrameworkElement, and in the simulator, it is a javax.swing.JComponent.
This blog post does include an example of a peer component, but it is targeting UWP:
https://www.codenameone.com/blog/uwp-native-interfaces-mix-c-java.html
Once you have a grasp of the material, you should look at relevant examples. Currently the most complete example I'm aware of of a cn1lib that implements a native peer is the Google Maps lib:
https://github.com/codenameone/codenameone-google-maps
You can see the Android native implementation here, and the iOS native implementation here
You may want to refer to the existing code for image capture in Codename One as well.
Android: https://github.com/codenameone/CodenameOne/blob/master/Ports/Android/src/com/codename1/impl/android/AndroidImplementation.java#L5788-L5811
https://github.com/codenameone/CodenameOne/blob/master/Ports/Android/src/com/codename1/impl/android/AndroidImplementation.java#L5701-L5714
Though it uses intent to open the native capture dialog, so it may not be too relevant.
IOS: https://github.com/codenameone/CodenameOne/blob/master/Ports/iOSPort/nativeSources/IOSNative.m#L2879-L2927

How to add custom image on native map in Titanium?

currently i am working on native map in Titanium for android and iOS.
you might have seen native maps on which a custom image layer or layout is being displayed, which will rotate and zoom according to the user input (currently i am not talking about annotations)
i have tried using annotation map tile too but it doesn't seems to work as the native map app i have seen
if you have any question or are not able to understand my question please let me know so i could clarify and get solution for one of you
Update:
Can you give a better explanation of what you've tried?
you might already know about mapbox.com and leafletjs.com, by using their library we could make customize maps and offline map in webview but i am looking for some Titanium module which could help me use native map of iOS and android for performing similar functionalities(i am avoiding commercial library and plugins as my app is not commercial app). i want to create map tiles which could be used for offline purpose as the user would have downloaded with the app.
what i have tried yet!!
1: http://i.stack.imgur.com/CLiNh.jpg
2: http://i.stack.imgur.com/QOLO7.jpg
in first image link i have given image in which i showing screenshot of map with rotation (if you notice compass) and the map tile moved accordingly to it
in 2nd image ... i had put a map tile using createAnnontation function, but unable to fix its layout remains same and it doesn't resize when i do zoom in/out too
I assume you are talking about custom tiles on top of a MapView.
There is an example module for iOS at https://github.com/benbahrenburg/benCoding.Map which used the Titanium map module as a base. It is a bit dated, but see the TileOverlay example and code and it will get you on the right track.
The best tutorial I've found on how to create the tiles is at http://www.ericbinnion.com/creating-custom-overlays-for-ios-mapkit-framework/
I've tried to create a similar TileOverlay functionality by forking the Android map module with limited success. I never got it to work as well as the native maps.
You could also check out using Mapbox with Titanium. There are great tutorials and tools for creating your own tiles layers and manipulating existing layers. Adam Paxton gave a great demo of it at TiConf in New York this year.

Windows 8 Image Slider

Is the image slider that the Windows 8 Camera app uses available as a control within the framework? It has nice transitions between images and provides previous and next buttons.
There is callisto refernce in nuget there you can find flipview like windows 8 app store
There is a FlipView control if you are referring to that.
You have some similar controls already built-in, such as FlipView if you want the previous and next buttons.
But if you want all the features in the image gallery application (with zooming capabilities), you will have to create your own component. I did, and it was quite painful, but sadly I did not have the time to package it properly to share with the community. Maybe someone else did it.

Is there a jump list control in WinRT like Windows Phone?

I do want this control in sometime for my project. For ex, I want it to be displayed when my app in snap mode.
You can use semantic zoom for that purpose.
Guidelines for Semantic Zoom
XAML GridView grouping and SemanticZoom sample
I implemented jumplist using semantic zoom. Might blog about it if anyone's interested.

How do I position in mono for android?

Hello i am new to Mono for android. I am trying to make a Calculator, in a normal windows forms application.
I can Drag a button or textbox to any position I want but how does that work in Mono for android, I want the buttons next to each other not only downwards. If I place buttons under eachother that go out of the framework I dont want that either..
I am not English il hope you will understand.
please help.
Android "supports", but has deprecated and doesn't endorse, pixel-perfect layout. Unfortunately the Windows Forms-style of dragging and dropping controls onto a design surface at specific pixel locations requires pixel perfect layout, so you can see the mismatch here.
For a Calculator, what you would instead want to do use a Table Layout or some other "resizable" container, so that your Activity can support the variety of device sizes that Android covers.