Can't create Prism pages using "prism template pack" - xamarin

When creating prism pages in Xamarin Forms app using the prism template pack I get the following error.
The parameter is incorrect.(Exception from HRESULT: 0x80070057
(E_INVALIDARG)
I am using VS2015, Prism Template Pack 1.7 and here's my project structure

My mistake was trying to create 'Prism' pages before modifying the app class to inherit from 'PrismApplication'.
I have just noticed that when using the template pack it automatically registers page for navigation within the 'RegisterTypes' method in the App class.

Adding to Muhammad's answer above, i also had to change the constructor to the following after inheriting from PrismApplication
public App(IPlatformInitializer initializer = null) : base(initializer)
{
}
And also had to change the Application to PrismApplication in App.xaml file also.

Related

Web Service can not find in MainActivity.cs in xamarin android OR how to call web service from mainactivity in xamarin android

I am Trying to call a web service in Xamarin Android Project. But when adding service reference in my project and trying to create reference of that web service it says 'HelloService' is a namespace but is used like a type.
MainActivity.cs
Solution Structure:
This is not an issue with xamarin.android, it's an issue with naming, i assume you have something like this.
namespace HelloService
{
class HelloService
{
}
Don't use same name for classes and namespace, more detail here

NavigationService Xamarin with Prism and Autofact can't find my navigation

I register my Xamarin form page with Autofac container on my App that inherits PrismApplication för Autofac
_container.RegisterTypeForNavigation<MasterLayoutPage_View, MasterLayoutPageViewModel>("MasterLayoutPage");
Then I navigate like this:
await NavigationService.NavigateAsync("MasterLayoutPage");
But it always says that MasterLayoutPage is not registered.
But when I check my Container for registered types it's there, fully added as the registration above.
Have I missed something? It worked with Unity I just change to Autofac.
I found this kind of odd and wonder if it might be a bug or if NavigationService with Autofact can't register the type as Unity can?
Seems like my problem was that I did not register the pages inside the override method RegisterTypes on App.xaml.cs I registered the types on the Initialize overridden method. It did work with Unity, not sure why it does not work the same way with autofac when it's the same container I use... Maybe prismApplication for unity has some difference then PrismApplication for Autofac, I shall take a look at the implementations of those two

Xamarin, How to invoke Shared code Method from Platform specific Dependency class

In Xamarin forms app, How can we invoke Shared code Method from Platform specific Dependency class.
I need to call one method implemented in my ContentPage class from my iOS dependency class.
Thanks...
There are different solutions to this:
Use a static method to call it where ever you need to.
Use the messaging center to send a message to your Shared/PCL project and do what ever you need. (link: https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/messaging-center/)
If this is a Custom renderer you can use binded command properties and Execute those in your platforms specific code.
In my case, what I did was having a static class called Helper, that contains all the static methods that I need to call on all platforms/projects.
Hope this helps.

How do you add htmlHelpers into the Spark virew

I want to use the htmlHelpers in my spark view but I keep getting the following errors.
error CS0234: The type or namespace name 'Mvc' does not exist in the
namespace 'System.Web' (are you missing an assembly reference?)
I have added the System.Web.Mvc assembly into the project. I have also added the following code into the module (just for the sake of getting it working - I'll probably need to add this code to the bootstrapper --- not sure how to do that yet!)
var settings = new SparkSettings()
.SetDebug(true)
.SetAutomaticEncoding(true)
.AddAssembly("System.Web")
.AddAssembly("System.Web.Mvc")
.AddNamespace("System.Web.Mvc")
.AddNamespace("System.Web.Mvc.Html");
I also tried adding the namespace to a _global.spark file
Can someone tell me exactly what I must do to use the htmlHelpers in my spark view please.
The default Spark base view for Nancy doesn't include the public HtmlHelper Html { get; set; } property.
You can see the default view here.
The Spark view implemented for MVC integration is here, and you'll see the Html property exposed, which allows your Spark view to access it and invoke helpers.
In theory, you can inherit from NancySparkView, and specify that as your base view in your Spark settings, and add that property along with references to System.Web.Mvc etc in that class and your views should then be able to call into the helpers assuming everything is referenced correctly.
I'm not a Nancy expert, but I'm sure the type of the View is different than that of Asp.Net MVC. So, theoretically, you shouldn't be able to use MVC helpers, since they require the Html property on the View.

AutoFac for Window Phone 7 - IContainter.Resolve extension method is not found

I'm building a fun application for Windows Phone 7. I'm using MVVM pattern and AutoFac for resolving the dependencies. I have got a classes AutoFacConfiguration holding a property as below
public static IContainer Container { get; private set; }
I try to resolve one of the registered types in some other part of the application like below
AutoFacConfiguration.Container.Resolve<IExpenseRepository>()
But this is not compiling. The compiler says Container does not have Resolve method. I know that IContainer derives from IComponentContext and an extension method with following signature does existing in the AutoFac assembly
public TService Resolve<TService>(this IComponentContext context)
Am I missing something here? I have just referenced the AutoFac.dll in my porject. This is downloaded from autofac site.
Have you added the relevant namespace as a using directive? For example, if the extension method is in class Foo.Bar.Baz, you should have:
using Foo.Bar;
in the source file that's trying to use the extension method.

Resources