How to Migrate WP7 App to Windows 8 Metro style app - windows-phone-7

I want to migrate my Windows Phone 7 App, to a Windows 8.
I started doing it after this Documentation: http://msdn.microsoft.com/en-us/library/windows/apps/hh465136.aspx
Those are the steps:
Launch Microsoft Visual Studio Express 2012 RC for Windows 8 and create a new Metro style app using C++, C#, or Visual Basic. Choose a project template that best matches your app layout and functionality. For more info, see Jumpstart your Metro style app using templates (C#, C++, Visual Basic).
Copy the folders, code, and asset files that you want to reuse in the new project.
In the Visual Studio Solution Explorer, click Show All Files.
Select the files and folders that you copied, and then right-click them and select Include In Project.
Perform a global search and replace to replace "System.Windows" with "Windows.UI.Xaml".
Copy the reusable parts of your original XAML code into the new project's XAML files, or into newly created XAML files as necessary. You can often copy and reuse the contents of page layout roots (typically Grid elements), but not the outermost elements (typically PhoneApplicationPage elements).
My Question starts at point 2: Let's say i have a page: Settings.xaml and Settings.cs. Do i have to copy both of them or none and add the code later? If I add Settings.xaml i get an error because of the tag:
<phone:PhoneApplicationPage ...>
like it says at point 6.
I dont have any Problems with my dll's or with my "normal" classes, which arent connected to a xaml.
And when i create a Windows 8 Page i don't know where to add my Code from WP7 in Windows 8
<Grid Background="Transparent">
.....Code.....
</Grid>
I hope you guys can help me out.

I agree with ColinE, instead of copying over all the files directly, create a new Windows 8 project and copy the appropriate XAML elements and C#. If you've created separate supporting .cs files, those should copy over fine, but if your code is all together in a file, you need to figure out what methods to copy over and where to put them.
In terms of what kind of app to use (empty, grid, split, etc.) that depends on your application and its purpose. Take a look at the Designing UX for Apps article to help figure out what will work best for your app: http://msdn.microsoft.com/en-us/library/windows/apps/hh779072.
Here is another MSDN article that talks about porting a Windows Phone 7 app to a Windows 8 Metro app: http://msdn.microsoft.com/en-us/library/windows/apps/hh465136.aspx
Hope that helps!

Probably the easiest approach to tackling your XAML files is to create new usercontrols / pages in your Win8 project using Visual Studio. You can then cut and paste the XAML from WP7 to Win8 piece by piece. You can also copy across the code-behind during this process.
There are a few too many changes to make it possible to copy the XAML / cs files across directly.

Related

Accessing resources XML from another library project in Xamarin.Android

I am trying to create a Xamarin.Android Component to send to the Xamarin Component Store, and I need to bundle my Colors.xml with it, so it is accessible to everyone using my component. I am setting the build action for the Colors.xml tp "AndroidResource".
So I created an Android sample application, when I add a reference to my library project's dll, I am able to use the colors defined, my project compiles and it runs, but I get no intellisense on Xamarin Studio. So that would be a bad thing for anyone using my library, as they would not be able to even see that the colors are available to use. You can see in this picture the colors defined are not available in the suggestions box.
If I add the Colors.xml directly into my project, I get Intellisense support, like this:
Is there a way to achieve the same result above when adding just the dll reference? Did I do something wrong or Xamarin.Android/Xamarin Studio doesn't support this kind of scenario?
EDIT: To be clear, I know this is a problem with Intellisense not being able to pick up the values, but is there anything I can do to make it work?

Image Transparency not working

I am using Windows 8 RTM and Visual Studio Express 2012 for Windows Desktop. I am trying to write an application that uses UIRibbon in Visual C++. (Because I have the Express version only, I don't have access to MFC; please don't use it in your answer.)
The problem has to do with the icons I use in the ribbon. Because Windows 7 compatibility is a requirement for this project, I cannot use PNG images; I am stuck with old-school BMPs. The problem is that, while some of the BMPs are displaying correctly, most of the images have black bounding-boxes around them. I suspect the problem has to do with the BMP files, and is not in the ribbon XML file or in the code.
The BMP that displays correctly I downloaded off the Internet as part of a sample that I adapted. The BMPs that don't display correctly I extracted from an ICO file, then converted to a 32-bit image using the System.Drawing.Bitmap .NET API. (This conversion process is in done in a separate program as part of my build procedure, not at runtime.)
My question is: Does changing the bit depth of a BMP in this manner affect the colors in the image? And, if so, can anyone point out a free tool that can turn a PNG file into a 32-bit BMP file that works correctly in the Windows UIRibbon?
Do you speak of the Windows Ribbon Framework here? If so, you wouldn't be able to use PNGs anyway as the framework supports BMP only for Windows 7. With Windows 8 you can also use PNGs. See the regarding MSDN article for more information.
For a free tool which converts your PNGs into compatible BMP files, you should have a look at the visual designer that comes with the "Windows Ribbon Framework for Delphi".
You can simply load you XML markup into the editor and add your pictures. The editor will then convert the added files into BMPs if required. You can also use the editor to check if your Ribbon definition looks right. It produces valid "Windows Ribbon Framework" XML markup, so you can use the markup file in any other language such as C++, C# or Delphi for your further application development.

Use ApplicationBar Icons from other assemblies?

I have a Page in a Windows Phone class library. This page has an appbar. I would prefer everything this page needs to be included within the class library so the setup list for consumers of this page / assembly is minimal.
However, When I set ApplicationBar icons, they get added to the class library project under the folder 'icons' just like normal, they show up fine in Blend, but at runtime they are no where to be found!
When I put the icons in the Windows Phone Application project all is well. However this is not my desired scenario as it is additional configuration / setup by the application author to use my pages.
I tried using the resource pathing using /{AssemblyName};component/icons/{IconName} but of course the AppBar needs them to be of type "Content" not "Resource". So I am thinking this is impossible but I wanted to know if anybody out there figured out how to do this.
Sorry guys. I just figured it out. I changed the newly added icons from "Resource" to "Content" but I forgot to set "Copy if newer" so they weren't getting outputted to the Bin\Debug\icons folder of the windows Phone Application. something to keep an eye on I guess.

Localizing Windows Phone 7 App

I'm having a little trouble getting localized resources files to work on Windows Phone 7. Here's what I'm doing:
Create a resource file, say "Strings.resx" (Build Action: Compile)
Create a key, say "TestKey" with a default value of empty string
Add a English resource file in the same folder with a value of "some English string": Strings.en-us.resx (Build Action: Embedded Resource)
Add a Japanese resource file in the same folder with a value of "some Japanese string": Strings.ja-jp.resx (Build Action: Embedded Resource)
In my PC Silverlight, WPF Apps that works fine when I change the Thread.CurrentThread.CurrentCulture. But in the phone I always seem to be getting the value that's in the Strings.resx file - an empty string.
I have tried using the designer generated code and wiring up the resource manager by hand and it does not seem to matter. Here's my code:
Type t = typeof(Strings);
_resourceManager = new ResourceManager(
t.Namespace + "." + t.Name,
t.Assembly);
_resourceManager.GetString("TestKey");
Tell me localized resources are supported on the phone... ;> What am I doing wrong? Thanks!
Update: Thanks Olivier for forwarding the link. I saw that as well but missed an important step. I didn't add the "SupportedCultures" node to my csproj. Made all the difference - hoping someone else doesn't loose two hours trying to figure this out like I did.
<SupportedCultures>de-DE;es-ES;</SupportedCultures>
Of course, localized resources are supported on the phone:
How to: Build a Localized Application for Windows Phone
I wrote a blog post that provides links to a bunch of Globalization / Localization guides for WP7. There is a Windows Phone 7 in 7 Training video that helped me understand the basics. After that it was simply a matter of learning how to do databinding:
The MSDN article shows you how to
setup the files and create the
LocalizedStrings class, but they then
assume that you know how to use that
class for data binding. Visual Studio
2010 and Silverlight handle data
binding differently than Winforms, and
it gets even more confusing since XAML
also has it’s own definition of
Resources that are different then the
.NET resources we just created.
Silverlight also uses the term
Resource to refer to files that use
the the Build Action of "Content”, as
these files get wrapped up into the
.XAP file similar to how files with
Build Action of "Resource” get
embedded into the .Dll assembly (ex:
loading an image from content or
resource files). I found that instead
of using the Text="{Binding
Path=resourceFile.resourceName,
Source={StaticResource
Localizedresources }}" XAML syntax it
was easier to use the following steps:
Open your primary XAML page (usually MainPage.xaml) in the Visual
Studio designer
Open the properties for the PhoneApplicationPage and set the
DataContext to be
Application.Resources –>
LocalizedStrings. NOTE: if you already
are using a DataContext object, then
you should integrate the
LocalizedStrings class into that
object so that it has localization
support.
Once the Page’s DataContext has been set you can change the data
binding for any control on the page by
simply selecting the property (ex:
text, checked, etc), selecting “Apply
Data Binding…”, and setting the Path
to Localizedresources.BtnText or
whatever the name of the desired
resource value is.

Embed image in code with Visual Studio

I remember reading once that there was a way to embed an image into a code file (e.g. a screenshot or diagram) in Visual Studio, but now I can't find any reference to that feature.
Is this possible to do, or am I imagining things?
EDIT: I don't mean embed the image in the executable, for use at runtime. I mean link or embed it literally in the code, for use by developers.
There is a plug-in for VS 2010 that can do this:
Plug-in
There is also a plugin for VS2012 and VS2013. At this moment installing for VS2013 does not seem to work for me though.
ImageComments extension on GitHub
You can embed images in your binary through the use of the ImageList control, which is typically used to store small icons for list controls, gridviews, etc., but could also be used for storing really any image for any purpose. A better solution would be to include a resource file and store your images there.

Resources