I am starting a cross-platform project in Xamarin, and I have some doubts that are me to prevent development. Initially the project is only for android and UWP but in the near future it will be also for iOS.
Questions:
1. I want to centralize all resources (strings for labels like "Name", "Age") in order to be consumed in the 3 platforms and when you have to edit this string, the change is made on all projects. What better way to do this? I need to do DataBinding on UI in all plataforms
[Xamarin.Android] I researched and heard of anything like "MVVMCross" but this forces me to extend my activities other own the MVVMCross and for example, and uencessito to take Android one ActionBar and for that I need to extend a class that can extender "AppCompatActivity" being, however, can only extend an activity and that therefore can not extend the actitivties from the MVVMCross.
Video: https://youtu.be/_DHDMNB_IeY?list=PLR6WI6W1JdeYSXLbm58jwAKYT7RQR31-W
Like:
public abstract class BaseActivity: AppCompatActivity // (with MVVMCross use MvxAppCompatActivity )
public class MainActivity: BaseActivity // (with MVVMCross use MvxActivity)
For assets, the correct approach is to keep the assets in the project, and if they are common to pass the PCL? I ask this because the assets on Android, iOS and UWP, the dimensions are different. What is good practice?
Thanks in advance!
For string resources and translations located just in your PCL I would suggest to use this library (very simple to implement):
https://github.com/xleon/I18N-Portable/, but you can also try and implement Resx files from your PCL.
Adding MvvmCross to your project just for localization would be just crazy.
But if you already use MvvmCross in your project, there´s a plugin for translations that uses json files at the PCL level: https://github.com/MvvmCross/MvvmCross/wiki/MvvmCross-plugins#jsonlocalisation.
For question 2: You can embbed resources in your PCL and load them from platform projects (ios/android/etc), but it won´t be as obvious as loading platform resources (you´ll need additional code). Thus, your assets and images usually change across platorms (different resolutions, dpi and design style guides) so trying to put them all together may complicate things more than helping.
About using specific MvvmCross Activities: that´s the way it works.
Related
I'm looking for free themes to style my private Xamarin.Forms application which has a non commerical purpose. I tried Syncfusion already, but they let me to create a whole new application which I don't like.
I want to look my application a bit nicer than the standard look and feel.
Xamarin.Forms applications can respond to style changes dynamically at runtime by using the DynamicResource markup extension.
For more detail, you can refer to this https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/theming/theming
I have a few problems with understanding of android tv development. First of all when i had launched android tv project and was trying to create custom interface for new activity, unfortunately i couldn't find any xml elements which could help me. From the example i got some ideas that whole interface provided by android SDK collected in many fragments. I just can modify colors, fonts, fonts size, transparency maybe animation and etc. But if i really need to customize structure of controls and WTF i wanna output "Hello World" inside label!!! Is it possible? I read all articles from this link https://developer.android.com/training/tv/index.html but it is still useless for me (maybe I am unique :) ). After this suffering with google guide, i have done a conclusion that the platform so new and there is no way to do some thing except only way that was provided by google. Am i right? If not, what should i do to find successful way?
The fragments provided by Google as part of the "leanback" framework are templates designed to make it easy for content providers to start publishing to Android TV without having to worry about the technical details of building a TV UI. The idea is that a content provider can create a channel just by feeding in their video content. This ease of use comes at a cost, customization is difficult or impossible with these templates.
However there is nothing preventing you from creating your own Activities and Fragments from scratch and implementing a completely custom UI for the TV, it works just like any other Android device. Add "android.intent.category.LEANBACK_LAUNCHER" to your manifest and see for yourself.
Is there a way to change the image of the pins in Xamarin Forms Maps. I want to make the pin a custom image, if it has to be done natively, can someone give me a simple example of it. Thank you.
To anyone coming to the later, this is now well supported in Xamarin Forms.
In essence you need to create a custom map class in your PCL or shared code that inherits from the Xamarin Forms Map and then create a Custom Renderer in each of the platforms' projects.
Those custom renderers will be different for each platform, dealing with the specifics of rendering icons and any pop up information shown when you click on that pin for that particular platform. You are not obliged to create a custom renderer for all platforms, for any that you don't a normal map will be displayed.
This is all now really well documented in the Custom Renderers | Customizing a Map section of the Xamarin Forms Developers Guide. That documentation walks through creating a custom renderer for Android, iOS and UWP and explains the code needed in detail. There's a lot of it, so I won't reproduce it here. There is also an accompanying sample solution here.
One point worth noting is that if you are trying to reproduce that code in your own project you will also need to add the images in the various drawable folders in the ProjectName\Droid\Resources directory, and also the two axml files in the layout directory.
Apparently this is quite locked down and you have to look at custom renderers to achieve what you are needing.
There is a discussion about this on the following link:-
http://forums.xamarin.com/discussion/17916/customization-of-xamarin-forms-maps-pins
, with specific reference to a project at the following link which someone has implemented custom image pins from the Assets folder:-
https://github.com/paulpatarinski/ShouldIWashMyCar/blob/master/Android/Renderers/MapViewRenderer.cs
I haven't tried this yet, however this would probably be a good place to start when looking to customize map rendering.
This project might be helpful to you. raechten/BindableMapTest
From the description:
Small sample for binding a collection to a Xamarin Forms Maps pins
(valid until binding directly to the Pins property will be supported
by Xamarin Forms directly).
Includes custom and clickable pins.
It has Android and iOS implementations.
I'm trying to build a MonoGame view inside MvvmCross on Android,iOS and WP8. On Windows side it's relatively easy to use dependency properties as a binding target, but how can I achieve a cross platform data binding solution that I can use on all platform?
This was covered in a previous MvvmCross version - see Insert a Monogame view inside MvvmCross monodroid Activity
The technical details have changes a bit since that post, but the core of the advice remains the same - use inheritance to add data-binding.
For example, if you want to adapt a FooActivity or FooViewController base class so that it can be used for MvvmCross data-binding, then you need to:
inherit from FooActivity to provide EventSourceFooActivity - to do this you need to add event notifications like those shown in MvxEventSourceFragmentActivity.cs
inherit from EventSourceFooActivity to provide BindingFooActivity - to do this you need to add all the members like DataContext from MvxFragmentActivity.cs
The process for Touch/iOS is very similar, but with iOS specific events and members. Take a look at any of the Mvx*ViewController classes to see what is involved.
This technique is also discussed in: Integrating Google Mobile Analytics with MVVMCross
I want to load the flex framework as an RSL (SWZ, using player caching) but I need to monkey patch a couple of bug fixes in the framework.
A number of forums suggest this is not possible. Has anyone gotten this to work?
Same thing as other answer to use frame1, but James Ward has some code to see: http://www.jamesward.com/blog/2009/03/10/flex-monkey-patching-and-framework-rsls/
I believe that only Adobe signed libraries can take advantage of the cross domain player caching mechanisms. Since yours won't be, it' can't.
It should be possible to create a RSL that doesn't take advantage of the player caching. This may be useful if you have multiple flex apps that all use the same Flex SDK RSL on the same domain and you'll let the browser cache them.
One of the guys on my team tried this about a month ago and said he had no problems. If your monkey-patched classes are part of your application project then it should work, since they are compiled into the SWF and basically "override" what's in the framework. You are not changing the Flex framework RSL, so it should still load and be cached fine. There isn't much published by Adobe to explain this but that's how I've understood it to work.
Create a custom Preloader for use and include your overwritten classes in there - that preloader gets loaded before any RSLs (such as the framework RSLs) so monkeypatched classes there will be in first and override the framework ones.
You can force the inclusion of a class by this pattern (put this in your customer Preloader class)
import com.yourclass.ClassName
private var emptyVariableTriggerInclusionOfImportedClass:ClassName
Here is another solution which creates separate RSL for monkey patched classes - http://www.hrundik.ru/blog/