I'm developing an application for WP8, and I would like to share some ViewModels with a windows store version, so I created a portable library, installed the portable version of MvvmLight and moved the code there.
From what I see, if I use the portable version of MVVM in a portable library, I have to use the same version even in the Windows8 application.
Now I have to bind handle the tap event in a ListBox to the ViewModel, to navigate to another view, and looks like I have to use the EventToCommand behavior, but this behavior is in the WP8.Extras dll of the standard version of MvvmLight, and I cannot add to my project.
How can I solve this? There is some way to bind an event to a ViewModel compatible with portable MvvmLight, or I possibile to install the not portable version of MvvmLight in the client App?
thanks,
Luca
The EventToCommand that you're using in WP8 is not availble on Windows Store Apps,
If you're working on a Windows8 app, than WinRTBehaviors will help you use all behaviors that do what you want (they can help only for Windows8.0 apps (the library is deprecated)).
If you are building for Windows8.1 than download Behaviors (XAML) SDK for VisualStudio 2013 they have InvokeCommandAction which does pretty the same thing
Related
I want to start programming a new application in C# oder VB with
Visual Studio Code.
Is it possible to program a GUI for my app in VS-Code and which libraries to use?
Visual Studio Code does not provide UI designing by itself. I have not seen any suitable extension to convert UI design into code, for VS-Code. How ever I think this is a good discussion (How can I develop cross-platform GUI application using .Net Core) about your second question:
Is it possible to program a GUI for my app in VS-Code and which
libraries to use
The C# support in VS Code is optimized for cross-platform .NET Core development. And you can't build applications like Winforms, WPF or Silverlight on .Net Core. They're gone!
So I am currently using Xamarin for multi-platform mobile applications. I really like the way this works, and I want to improve my flow. My developers have said that they would be much faster when programming natively (i.e. Swift for iOS in XCode).
I have looked for a solution, where I can create a shared project and use it in native apps, but I have only found ways that involve programming in one language for all platforms.
Is there a way to create a shared project, which can be imported into a native application (or better, can be run together, like a shared project in Xamarin)?
The language for the shared code is not important, as long as it isn't slow.
My developers have said that they would be much faster when programming natively (i.e. Swift for iOS in XCode)
Swift can be used natively for iOS apps. RemObjects' Silver is supposed to make Swift ready for Android and .NET. I've never tested it. Try it out, it's free.
RoboVM can be used to write iOS apps in Java. I didn't try it out either.
Language mixing with Xamarin
In case you want to mix Swift code with C# code using Xamarin then you can bind Objective-C compatible Swift code and use it in iOS projects only. You are not able to execute Swift code on Android or Windows Phone! It's not possible to write platform independent business logic in Swift and and use it in a shared library or PCL with Xamarin.
You face the same restrictions for Java code on Android: You can bind JARs and use them in a Xamarin.Android project but you cannot use them on iOS or Windows Phone.
You are also unable to execute C# code in a Swift based app on iOS or in a Java based app on Android.
You can use native code in Xamarin apps via Binding Libraries. You cannot use Xamarin libraries in native apps.
If the goal is to use truly native tooling, in their standard languages (meaning not Xamarin) and still share code between iOS and Android, this can be achieved by writing your non-UI code in C++.
Here's a very interesting article about how Dropbox does exactly this.
C++ is natively supported on iOS and it is very easy to interface
between Objective-C and C++ using Objective-C++.
On Android, calling into C++ can be done through the NDK, which
reportedly is not a pleasure to use. Dropbox found Google’s meta-build
system gyp to work reasonably well. In addition, the Java Native
Interface is a pain you have to accept. But none of these issues is a
roadblock, and Steven expressed hope that Google or the community will
build better tooling support over time.
And here's a simple example of how to do this from another StackOverflow post
We have an line-of-business app that runs on Windows Mobile. It's a Winforms app with a local SQL CE database and gets its data from a WCF Web Service running on the server.
Now customers are always asking "why don't you make a version for iPhone/iPad/Android/Phone 7 etc". My boss asked how hard this would be. My initial answer is very hard especially since I would probably be the only person doing the work. I don't have any experience outside my Visual Studio happy place.
Now I've come across MonoTouch and MonoDroid. They appears to offer an easy solution but I'm sure there are lots of issues. I doubt that I will be able to just compile my app for Android.
I'm inclined to suggest that it would be far too much work and that the only realistic solution is a mobile web site with several versions of each page for different screen resolutions. Unfortunately the existing app has a local database and is "sometimes connected" so that won't cut it.
Any suggestions and tips before I waste a huge amount of time?
Cheers
Mark
I doubt that I will be able to just compile my app for Android
That is correct; you won't.
So, background: the design philosophy of MonoTouch and Mono for Android is to bring the "core" .NET and C# experience to iOS and Android while also exposing the underlying features of each specific platform. Whereas PhoneGap and Titanium abstract the underlying platform (for a "write-once, run-anywhere" vibe), MonoTouch and Mono for Android provide no platform abstractions and directly expose the underlying platform types and members.
The result is that MonoTouch programs use MonoTouch.UIKit.UIButton, which directly wraps the underlying CocoaTouch UIButton type.
Similarly, Mono for Android programs would use Android.App.Activity, which directly wraps the underlying Android android.app.Activity type.
Common across both platforms are the "core" framework namespaces and types which you find on .NET, .NET CF, Silverlight, Windows Phone 7, and Mono: System, System.Collections.Generic, System.Linq (yes, Linq-to-Objects), System.Xml.Linq (yes, Linq-to-XML), System.IO, etc., etc. For example, see the assemblies included in Mono for Android.
So, can you use your existing Windows Mobile app as-is on Android? No, because Mono for Android doesn't provide System.Windows.Forms.
However, it should be possible for you to refactor your existing code to follow a Model/View/Controller design pattern (or MVVM, or...), abstracting away the UI (View) so that you can replace it for various platforms, e.g. an iOS UI with MonoTouch, a WP7 UI with XAML, an Android UI with Mono for Android, an HTML UI with ASP.NET MVC, etc., etc. You won't get a "write once, run anywhere" experience, but you will be able to provide the user with native user interfaces which are consistent with their chosen platform.
For example, see the MIX11 Conference Apps, which utilize a common code base while providing platform-specific UIs for iOS, Android, and WP7.
look at titanium and phonegap.
My suggestion is to have a quick look at WP7. It's quite easy to jump in to, even more so if you have Visual Studio (which you do) and C# experience of any sorts. Then you should be able to more easily guesstimate how long it would take you to develop a C# application (and possibly port that to Android using MonoDroid).
And yes, Titanium & PhoneGap are options, but I personally think MonoDroid looks better.
What platform are you getting the most requests for? I am guessing Android, as that seems the most likely. I have seen a lot of people saying MonoDroid is really solid.
For web applications you can have one designer create a mockup, and then another one (Perhaps Off Shore) generate CSS, templates, themes, skins...whatever.
How can you do something similar with Monotouch?
How would it differ from what can be done in SDK workflow?
Can you use some of the same tools as for WPF/Silverlight?
(And still be like a native iPhone app).
MonoTouch doesn't use WPF or Silverlight at all. The virtual machine is similar to the Silverlight one, but that's where the similarities stop. MonoTouch uses Apple's tools for development, including Interface Builder, which is a kind of UI designer, and in theory would replace the WPF editor in Visual Studio or Blend.
In reality though, most developers prefer to simply write most or all the UI in code, because of the simplicity of the API. Designers need to work directly with the developers, not the tools, to make sure their design works and can be implemented.
This is a question to all of you out there who develop for both Android and iPhone. How do you maintain support for the two platforms? Specifically, do you
maintain the two products totally separate from each other?
create "native" GUIs in Java/ObjC and a "core" library in C/C++?
write both versions in the same language (e.g. Java) and a third-party tool to generate code for each platform?
write everything in the same code base and use an even more fancy tool to generate native bindings for each platform?
I do create "native" UIs in Java/ObjC and core library is usually in C/C++. That's when the application I am maintaining requires a complex core library.
When the application is simple enough, I just maintain two code bases: Java/ObjC-CocoaTouch.
As far as I know, there are no fancy tools to generate binding for each platform. Maybe Monotouch will officially support Android at some point and you will be able to do everything in C#: Android, iPhone and Windows Phone 7!