Android land / port layout structure not working - c#

I have included the following folders within my project:
layout
layout-land/
layout-port/
I placed the my main.axml file in all of them, with a couple of tweaks to the UI of course. But when I change the orientation on the device, noting happens.
I'm doing basically the same as this tutorial, but I'm making use of Xamarin and Visual Studio: http://www.how-to-develop-android-apps.com/how-to-make-a-landscape-layout-in-android/
Not really sure what I'm doing wrong?! Could someone please assist?

Okay, so basically I had a folder called layout-normal. This caused the layout-land to be ignored for some or other reason. I removed the folder from the project and it worked!

Related

How to regenerate Resource.designer.cs file Xamarin Android

So I am new to Xamarin studio and have been stuck on a little bit of a frustrating issue. Every time I make a change within the resources file, the Resource.designer.cs file does not regenerate and recognize the new changes. Does anyone know how I can update the changes so that I can interact with newly added widgets? I appreciate the help.
Check your Android's .csproj file and make sure the following AndroidResgenXXXX properties are included within a PropertyGroup (within the Project)
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AndroidResgenClass>Resource</AndroidResgenClass>

Xamarin.Forms Windows 10 Universal Error "CS0103 InitializeComponent does not exist"

I have a working Android Project with a .Droid-Solution and a SharedProject. I started the App on my phone and it works great. Now, I just added a blank Windows 10 Universal Solution and did the instructions here: http://developer.xamarin.com/guides/xamarin-forms/platform-features/windows/installation/universal/
Anyway... I did nothing else. Just followed the instructions and tryed to start the Windows 10 Universal app, but I get this error:
"CS0103 C# The name 'InitializeComponent ' does not exist in the
current context."
I googled a few times, but didn't find something that helps.
I also tryed the example here: https://github.com/jamesmontemagno/Hanselman.Forms with the same error.
Does someone know this error with Xamarin.Forms and Windows 10 Universal Apps?
Everytime you create a .XAML page in Xamarin.Forms, you are using partial class definitions in three different places.
Your actual .xaml file will have a Class="" attribute on the root element that defines the namespace and class name.
The actual root element type will define the base class that your new .xaml page is subclassing. By default, that would be ContentPage.
You also get a .xaml.cs file that is linked which contains a partial class definition as well. This is your code behind file, where you put page specific code, this is also where the InitializeComponent() call is called from the constructor.
This call serves to parse the xaml contents and fill out the references to all the views you gave ids to using x:name="something" in xaml.
InitializeComponent() is automatically generated by xamarin, it is part of the output of your project and it should get re-generated each time you edit your .xaml file.
In order for this to happen, in the properties of your .xaml file Build Action needs to be set to "Embedded Resource" and the Custom Tool needs to be set to "MSBuild:UpdateDesignTimeXaml"
Now, even with these values set correctly, there are bugs in Xamarin which can lead to the file not getting generated and you getting the error.
The absolute first thing to try when you get this error is to right click the .xaml file and click on "Run Custom Tool".
You only need to do this once, on ONE xaml file, the tool will automatically run for all the .xaml files in your project.
This is somethign that I have to do about once a day during my normal development and it started when i switched to VS 2015. Your mileage may warry.
Another very important thing to check is the BuildTargets in your .csproj file.
The way Xamarin is able to do it's thing is by specifying build actions that call into it's DLL that you get when you install the Xamarin.Forms nuget package. Sometimes the build actions import line get's messed up and this causes all sorts of problems.
Unload your .csproj and find the line that imports Xamarin.Forms.targets.
It should look something like this:
<Import Project="..\..\packages\Xamarin.Forms.2.0.0.6484\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\..\packages\Xamarin.Forms.2.0.0.6484\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
make sure that the version in here matches the version of Xamarin.Forms from your packages.config file, then make sure that you can actually navigate to your project's root folder, and find the actual file the important line is referring to. Ie, packages\xamarin...\Xamarin.Forms.targets
A common thing to do is to delete everything from \packages\ and let nuget re-download everything on your next build. Just make sure the version in your .csproj import and the version in packages.config is the same.
If all of these are done, you should have a valid generated partial class that implements InitializeComponent() and the errors should dissapear.
Just as an update to this:
New, clean Windows 10 Pro installation with all updates in a VM.
New, clean Visual Studio 2015 Community Edition installation with all options selected and all updates.
New project: Blank Xaml App (Xamarin.Forms.Portable) with nowt but generated code.
The project will not build as InitializeComponent in App.xaml.cs does not exist in the current context.
Opinion: this Xamarin add-on is a free add-on on top of a free product, but even so this kind of thing doesn't really inspire you to use it...

The name "X" does not exist in the namespace "using:Y"

After reading every article here and trying every suggested action I'm out of things to try:
I have a namespace issue in Visual Studio 2015 - in a XAML file in UWP.
The concrete error message is:
"The name "FieldManagementViewModel" does not exist in the namespace
"using:StudyConfigurationClient.ViewModels"".
This is my XAML:
This is the structure to show, that the folder and file actually exists, folder structure equals namespaces in this project:
I've looked all references and namespaces through, I've repaired Visual Studio 2015, I've cleaned and rebuilt several times and changed platform for the build back and forth - I'm out of options.
What worked for me:
Remove the problematic XAML tag, so that solution will build
Rebuild project
Restore the tag
I think VS falls into a chicken & egg situation here, in that it needs newly added classes built so that XAML can see them, but it can't build them because XAML can't see them.
Just add this solution to this probelm:
- Close and re-open Visual Studio
In my case the problem occurred in App.xaml. In the properties for App.xaml the BuildAction had somehow been changed to Page. After restoring the BuildAction to ApplicationDefinition the problem went away. (See also this related answer.)
Thanks for helping - this issue magically went away when I pulled a change from git, which shouldn't affect this in any way. Sorry for not being able to help others, but I haven't got a clue about what happened.

NativeCSS & Xamarin.Android

I need some help getting NativeCSS running for Xamarin.Android (in Xamarin Studio).
What I have done:
-Added .dll to References in my Xamarin project.
-Added styles.css file to different folders (root, Assets, Resources, and also to the debug output folder). (Question: What is the folder, NativeCSS expects the .css file??)
-Added the following code to my MainActivity.cs:
NativeCSS.StyleWithCSS("styles.css",
new Uri("http:url"),
RemoteContentRefreshPeriod.Never);
But I can not see any style changes of my project.
I hope somebody can help me.
I really appreciate every help.
Checkout the sample project TaskyDroid, which does exactly what you want:

WPF adding Icon to windows cause Property Error

Here is the exact error I got.
(source: clip2net.com)
The favicon.ico has been added in the project as a resource and I have set to "Resource" the Build Action.
(source: clip2net.com)
I found some solution that require to add some code. My question is why I can't do it with the Visual Studio Interface?
I had a similar problem with close.bmp. I renamed it to close-image.bmp, and it fixed it. But right now, I tryed to rename it into close.bmp again, and today it works. Seems to be a problem with solution... Read this discussion:
http://social.msdn.microsoft.com/Forums/en-US/vswpfdesigner/thread/b03061e5-5500-442f-9c88-a6d82f97c2b7
Also, your settings are right. You need to include it and make 'Build Action: Resource'
If your icon is under a folder, have you included the folder name?
1237239323-clip-25kb http://clip2net.com/clip/m0/1237239323-clip-25kb.png
I just tried in Visual Studio 2008 SP 1 and it worked. I dragged the file into the project, and I was simply able to type "favicon.ico" in the property pane.
Are you sure it's at the root level of your application? If you have it in a subfolder in the project it will require the full relative path (like "icons\favicon.ico").

Categories