Create a .dll Library consisting GUI Components windows phone 8 - c#

I have to create a library which i would like to reference in other project. However I would like to include in other projects. So basically when there is a button click I have to switch to the application pages created by my library. Is there any way to do this kind of project in windows phone SDK. I am using visual studio 2012 for windows sdk 8.

You can create this kind of an library using the standard Windows Phone Class Library -project. You can add pages and classes to this project as if it was a regular Windows Phone Application-project. To navigate to page which resides inside a class library, use the examples provided in here: http://www.geekchamp.com/tips/wp7-navigating-to-a-page-in-different-assembly
Example:
We have created a simple class library which contains pages for dealing with PayPal payments. We reuse this component in few of our apps. The library contains few pages:
When we want to use that library in our app, we just reference the DLL. After that, we just have to navigate the user to the correct Uri:
frame.Navigate(new Uri(string.Format("/Adafy.Payment.Client.WindowsPhone;component/Pages/ProductDescription.xaml?productId={0}", productId), UriKind.Relative));

Related

Convert Existing Windows 10 UWP Application in Android

I've found a few examples, as I in a Xamarin.Native use a Windows UWP. But that would mean that I a Xamarin.Nativ in a Windows UWP Convert.
I would like convert a finished Windows UWP application to the target Android or iOS. Is that generally supported or needs my UWP application rebuild again with Xamarin?
Links:
Adding a Universal Windows Platform (UWP) App
Getting Started with Xamarin.Forms 2.0’s Windows 10 Preview
Unfortunately asfar as I know there is no converter that allows to convert UWP app to Android app straight forward.
There are few ways to make the whole process a lot much more easier (so you can create your Android app faster).
If you wrote your UWP application and separated common code that can be used in the other applications you can also use it in Xamarin.Android app - the best way is to have PCL with the common code.
It is also important which type of Xamarin app you would like to create:
1) Xamarin Forms - common UI for each app: Windows, Android and iOS.
There is one shared code that can be used by them. Remember that Xamarin Forms apps are generally speaking the best for displaying the data and they are limited with reference to platform specific functionality.
Please see below to read more:
https://docs.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/sharing_code_options/
2) Xamarin.Platfrom (so Xamarin.Android and Xamarin.iOS):
Here you can create native UI foreach of the project (Windows, Android and iOS) and access specific platform functionality.
With reference to the code - you can put common code in one PCL and have access to it from each project.
Please see this site - here you can find different Xamarin options to create cross-platfrom apps:
https://developer.xamarin.com/
Firstly, if you want a shared code, using Portable class library, you can use the same code for all the platforms including WPF, Android and iOS. First of all what you can do is convert the codes that is used again and again in the PCL (Portable Class Lirary). Once you get used to PCL, you can easily work on any platform you want.
As the Android, iOS are different from windows, a lot of .net framework functionality is not supported in PCL. Although, once you create the basics in PCL, you can integrate the class library in android as well as iOS.

Reference Universal Windows Library from WPF application

I am currently working on porting an existing wpf app to a universal windows app.
The existing application is fairly simple and is structured as a normal wpf project, containing the ui layer and filesystem interactions, and a class library containing the main application logic.
I was able to transfer the class library to a Universal Windows Library (windows 10 sdk) without making any substantial changes. This Universal Windows library exists in its own project inside the same solution as the original wpf application.
In order to minimize complexity, I would like both the upcoming Universal Windows app and the wpf app to reference the same library. However I am unable to add a reference to the universal Windows library from my wpf project. The library appears in the "add reference" dialog in visual studio, but after selecting the library and clicking OK, I am presented with a message saying that the reference could not be added.
Is what I am trying to do currently not possible, or is there something I'm missing? It seems foolish to need to save the same code into two different library projects for it to be usable.
You should be able to select the target frameworks of the class library by right clicking the project > Properties > Library and under targeting hit change, and select .Net framework X on your machine. Then, (aside from incompatible API's in your PCL) you'll be able to reference the project

C# Windows Store App How To Call Method of Windows Forms Project

I've created a Windows Store App that's running on a tablet that has Windows 8.1 as it's operating system. This app needs to print reports so I've created a report using Crystal Reports For Visual Studio. Because the Windows Store App and Windows Forms projects are on two different frameworks within the same solution, I've not been able to reference each project directly like I would in a normal solution.
I have managed to pass values between the Windows Store App project and Windows Forms project by using a Portable Class Library... but now the problem I am hitting is how to call a method that prints the report from Windows Store to the report located in Windows Forms?
I've tried referencing the Portable Class Library from my Windows Forms project but I get a circular dependency exception... which makes sense. I've further tried creating another Portable Class Library to call the Windows Forms method... but apparently Portable Class Libraries can only reference other Portable Class Libraries.
Surely their has to be a way to do this? Any suggestions would be greatly appreciated!
Windows Store App in C# and Windows Form Application use different .NET Framework, so you can not reference a Windows Form project in Windows Store App project.
Portable Class Libraries could not resolve the communication problem between 2 types of project. The possible solution is using the communication framework like WCF.

c# file or MainPage.xml.cs in Cordova/Phonegap windows project

I am converting my app from a WP8 project to a windows project. If you run the command
cordova platform add windows
Cordova will create a solution with 4 projects, one for Windows 8.1, 1 for Windows 8, one for Windows Phone and the shared project. From what i can see, these are javascript projects, but i need to run some c# code to start a background service when the app starts. In a WP8 project you can add this code to the Mainpage.xml.cs file.
Is there no c# code that runs in these types of projects, or can you attach any code to run upon startup? How do people start background tasks in these apps else?
In Apache Cordova main page, there is a bunch of links to download Cordova Component for each platform. Choose the one for WP8 GitHub repository, and you will be redirected to
https://github.com/apache/cordova-wp8
Download the repository as a Zip from the right hand side of the page, after unzipping the file, you will happily find that the Cordova library and the project template are written in C#.

Share dll between WP7 and WP8 application

Usually it is recommended to have two projects for both wp7 and wp8 platforms. Wp7 project contains .cs and .xaml files, and WP8 project contains links to that files.
I think that there is no reason to compile non-platform specific business logic code twice, since it can be referenced to WP8 project.
I'm thinking about following solution structure:
Business logic dll compiled for wp7 (not a PCL)
UI comliled for wp8
UI comliled for wp7
Such application can be compiled and I can deploy it to device/emulator.
The question is: will this app pass certification in Windows phone store? Or it is necessary to recompile shared dll?
UPD:
My crazy idea was born after this steps:
Create new WP7 app (WindowsPhoneApplication1)
Create class library targeted to WP7 (WindowsPhoneClassLibrary1) Use it in WindowsPhoneApplication1
Use Upgrade to WP8 menu. WindowsPhoneApplication1 will be updated to WP8, but the referenced project will be still targeted to WP7!
Such app can be deployed to WP8 devices.
Unless you use a Portable Class Library, you'll need to have separate project files, and compile separately for WP7 and WP8.
Thanks to Claus,
I made some research, and it looks like the answer is - you can use such solution.
I didn't find related information in documentation, but here is a proof from one of MSFT tech. evangelists from Netherlands: link to blogpost
The basic idea is to move all our code that can be used from both our existing Windows Phone 7 app as well as the Windows Phone 8 build, which we will add soon, to a Common project in the solution. The bad thing about this approach is that we have to create the Common project as a Windows Phone 7 class library, which will be used in our Windows Phone 8 build. I haven’t really noticed any negative impact of this decision in my existing apps, but note that you will be referencing a Windows Phone 7 library in your Windows Phone 8 build.
So it is a possible, but not the best solution.

Categories