Managing Visual State - winrt-xaml

I have a universal Windows 8.1 app that uses the same code in the code-behind files but has significantly different layouts for PC/tablet and phone. To make the transition to Windows 10 easier (and so I only have to manage one code-behind file) I want my project to use only one XAML file. I don't know much about view states but I'd guess that's how I'd keep separate layouts for the different platforms. What's the best way to go about this?

You can listen to the Window.Changed in your code behind and call VisualStateManager.GoToState to tell your UI to apply a VisualState you've defined.
In Windows 10 there will be AdaptiveTriggers that will eliminate the need to manually listen to the Window.SizeChanged event, so it's the closest and easiest analogy.

Related

Xamarin.Forms + Custom Renderers vs. Xamarin.iOS/Xamarin.Android

I recently started using Xamarin.Forms for a project. Like the documentation mentions, it's great for prototyping. However, I'm really starting to notice limitations of the shared concepts for UI design. In particular, the inability to set custom button content (such as an image) is aggravating. I'm sure there will be several instances where I'll want to change how controls work.
The way I see it, there are two routes I could take. One, continue using Xamarin.Forms and make use of custom renderers. Considering I would still like my UI code to be shared, but also customized from the basic Xamarin.Forms controls, I'm leaning towards this option. Two, use the native Xamarin projects (Xamarin.iOS, Xamarin.Android). This would give me full control over the UI for each platform, but it would also mean more code to maintain.
Like I mentioned, I'm currently favoring the option to use custom renderers with Xamarin.Forms. Could I get some insight from those who have used one or (preferably) both options?
I've mainly used Xamarin.Forms. For the right kinds of apps (ones that are, well, "Forms"-like), it works pretty well.
Writing custom renderers isn't that hard, but the documentation is, unfortunately, not that great. Depending on what you're doing, it can be a bit tricky at times translating between the native control and the Forms layout engine. However once you get the hang of it, it makes sense, and now that the code is open source, you can peek inside to see how the "built-in" controls work.
There are various extensions that add more controls. Some are free and open source, like XLabs.Forms. So the control you need might be out there already.
You can use mechanisms like TapGestureRecognizer to turn an Image or a Label into a button, so just because the built-in Forms Button is really, really lacking in customizability, you can sometimes find other ways to get the same effect and still stay within pure Xamarin.Forms.
Hope that helps!
XamarinForms is good for sample application who don't need to use a lot of specificity of the device.
For complex applications, I advise you to start on Xamarin Ios and Android.
It will take more time to take charge but you will see it is much more permissive

Xamarin.Forms or Xamarin.Android/Xamarin.IOS

I am new to Xamarin and not sure if chose Xamarin.Forms to create a application for ios and android platform has a problem or not.
The application has some features below:
The application will be able to running some code in background without launching application by user.
The application can be launched by a href link or a notification.
The application is able to launch a builtin Camera application, and receive picture data from Camera application.
Thanks,
Bo
The features you are mentioning can be done with both. Actually, anything you can do on Xamarin.iOS and Xamarin.Android can be done with Forms. Because Forms is only an abstraction layer for the UI which is installed by a NuGet package.
Now, having that said when to use Forms or when to use iOS/Android? It is mostly about UI. Are you going to do some advanced or platform specific stuff is is easier to implement that with the platform specific project.
If you UI will be the same in both platforms and mostly consists of some lists and input fields, then that is a very good candidate for a Forms project.
Notice how I said it is easier to do in the platform specific projects. Again here, you can do anything in Forms as well by the means of Custom Renderers, it is just a bit harder to do.
Ideally try it out yourself and see what suits you best.
In regard with your need to execute code in the background. This will be tricky and is very dependent on the platform that you're on. You will definitely have to write platform specific code for that for which you can use the DependencyService to abstract it to your shared code.
However like AlancLui mentioned executing code in the background isn't something that is easy to do on mobile. On iOS it is restricted to accessing location data or playing music, but still your app needs to be running (in the background). Android has something called Services for this, which makes it a bit easier.

Converting a .Net dll to a .Net Core dll

We have this application written in Visual Basic (Windows Form Application) and I am tasked to convert it to Universal App (UWP). the said application uses a dll that is specific to .Net Framework so in order to convert it into a Universal App, I need to have a dll that is targeting .Net Core.
Is there a way to do it?
I know nothing in dll stuffs, can someone enlighten me up? Any help will be appreciated.
Your best bet in this case is the Desktop App Converter.
In summary, what that does is takes your existing .exe application and converts it to an Universal Store appx. In most cases this can happen without any code changes, and the resulting app can be deployed to the Windows Store or other UWP deployment channels (MDM solutions). It also lets you add some of the UWP features such as Live Tiles or Push Notifications, while others won't be possible with this (Adaptive Layouts). The application, though running under the new Application Model will still run with the same permissions as the original .exe (not sandboxed).
So, if you are being asked to convert the app for (some of) those reasons, it might be your best solution.
If this does not work for you, there is no other choice than a complete rewrite at this point since UWP does not support Forms, you will need to use XAML, so your entire UI stack needs to be redone at which point, a complete refresh usually makes more sense.

Convert MainApp from an MFC application into a secondary dialog

Hello fellow programmers, I come back to you to ask for a quick way to do something with MFC applications.
I have two MFC applications, and I want one to launch the other in a separate thread, so I can have both services running from executing a single exe file.
I'm actually new to MFC so I don't actually know what options I do have. Tried some dirty things but I keep getting duplicated resources problem, not to mention both apps start with BOOL CMainApp::InitInstance() and I'm guessing there is no way to have two initialization instances.
That being said, is there any quick way to rewrite one of the apps to become a secondary dialog without causing too much headache?
Thank you in advance, and excuse me if I'm asking something weird or easy.
It depends on what kind of MFC applications are they? MDI, SDI, Dialog-based?
Here are some options:
If the secondary app is Dialog-based, the conversion is pretty simple: you need to move implementation files for that dialog into the first app and merge the resources.
If both applications are MDI - you can merge their Document Templates so that the first app will be able to operate on all document/view types.
Otherwise - did you consider simply spawning the second app via CreateProcess()? What is the significance of them being run from "a single exe file"?

Windows 8 metro style apps and window hooks

I am new to both window hooks and Windows 8 metro apps..
I would like to develop a background service/process that:
Checks the "properties" of the metro app that a user just tapped to start (e.g. app that plays music, text document creator app, ...)
Based on the properties found, activate other applications (i.e., before starting the text creator application that the user just tapped, make him select the font face from a popup list)
I am planning on using window hooks to do 1 and 2..
Is this possible?
Thanks!
It is not possible to hook Windows or intercept the launching of a Metro style app from within a Metro style app itself. While it may be possible to do so with a service installed on the machine in a classic way, doing so would be totally undocumented and unsupported. You would have to reverse-engineer the app launching process to have any chance at making it work.
Check this out..
http://social.msdn.microsoft.com/Forums/en/wcf/thread/43df6c8f-f1e3-4aba-af0a-7c4e1db477b6
You can only write client applications using Metro, not server applications.
In your scenario, if you want inter-app communication, recommended way is to use 'Contracts' which are explicitly started by the user.
I'm taking a blind guess here using your 1 and 2 points. Do you intend to handle a specific file type ? say .txt or .wmv ?
If this is your intention, please check here http://tozon.info/blog/post/2011/10/11/Windows-8-Metro-declarations-File-Type-Associations.aspx
There's also a good set of MSDN documentation about this.
You may use API hooking. Check this thread:
http://forum.nektra.com/forum/viewtopic.php?f=9&t=6228

Resources