DaCh
DaCh

Reputation: 931

Xamarin forms. get winPhone's App Prop's in PCL

I'm trying to get the prop's from my WinPhone solutions in my xamarin froms project so that i can use them in my PCL.

So that in my App/PCL can do something like

App.WinPhone.Prop = 2; Or Var temp = App.WinPhone.Prop

thank for your time

Upvotes: 0

Views: 28

Answers (2)

Adam
Adam

Reputation: 16199

You need to create a new class in your WP Native project. e.g.

[assembly: Dependency (typeof(MyProperties))]
namespace MyNamespace
{
    public class MyProperties: IMyProperties
    {

         public string TheProperty { get { return "something"; } }

    }
}

Create the appropriate interface in your PCL.

Then in your PCL do

 DependencyService.Get<IMyProperties>().TheProperty

This webpage has more information: https://developer.xamarin.com/guides/xamarin-forms/dependency-service/introduction/

Upvotes: 0

Tomasz Kowalczyk
Tomasz Kowalczyk

Reputation: 1923

Maybe this plugin from James Montemagno will help you.

Upvotes: 0

Related Questions