Xamarin Forms set a ToolBarItem icon to a resource image - xamarin

I am trying to set the icon for a ToolBarItem to an image loaded from an embedded resource in my Xamarin Forms project. Something like this:
SearchToolbarItem.Icon = ImageSource.FromResource("Namespace.folder.imagename.png");
I am aware that this does not compile, but it gets to heart of what I am trying to do; set an icon to an image loaded from an embedded resource.
I know I could add the image to each individual project (e.g. iOS, Android, etc.) and reference it via a string, but I would prefer just to have one image in the Xamarin Forms project and just use that. Thanks!Q

The easiest way I found is to create link of the png file in Android resources. Then you just use it as local native resource.

Related

xamarin forms start nativ uwp page

any idea how I can start a native UWP page from a Xamarin Forms page?
The reason why I'm asking:
I have a XF application that needs to start a UWP library after a click event.
This library provides a special ORC reader.
Therefore I created a dependency service to run the platform specific function.
What I need now, is to open that UWP page, that contains the "Camera stream" to show the user what he is currently scanning.
And this is where I am hanging at the moment.
In my class that is called from the dep. service, I
myPage mp = new myPage();
But how can I show the new page?
Frame fr = Window.Current.Content as Frame gives me the error, that this page cannot be converted from a XF Frame to a Window Frame.
Or is there generally another way to handle this? Some advice would be great.
This sounds like a custom renderer.
Create a new OcrView class in your shared project inherited from View.
Place it on your Xamarin Forms XAML page.
Handle the OCR component in the UWP renderer.
Have a look at the Implementing a View section on this custom renderer overview

Use a PDF for iOS application icon

For asset catalog icons, Xamarin lets specify a single PDF, and it does all the bitmap conversion for you.
Is there a similar method available for the application icons? It would be nice to not have to generate by hand all the different sizes required?

Xamarin - how to center a launch screen image (iOS)?

I'm using Xamarin for Visual Studio, and am getting frustrated trying to do what I would think should be a very simple thing: creating a launch (splash) screen for iOS, that has a single image that is centered on the screen (vertically and horizontally centered).
I'm creating it the recommended way, using a storyboard (other methods, like using an assets catalog, are considered deprecated as of iOS 9). In the storyboard, I have a View Controller, which contains a View, which contains an Image View. In the Properties pane, I've tried messing with the Mode (in Widget tab), and I've tried playing around with contstraints - which I think might be the key, but it is difficult to understand how it all works together.
You need to add the Splash screen in the applications properties (Launch Images). You need to create the image and upload it via that section. I couldn't find anything saying that the use of Asset catalogues are depreciated.

How do add an icon or image to your application in application builder

How do I add an icon to my finished application in apex 4.2.6 .. Not seen this in any of the books..in both desktop and J-query mobile UIs
You cannot modify the icons very easily. These application icons are some background images that are displayed using the CSS Sprite technique.
For each of the app report it's generated a class attribute from internal packaged app metadata.
That is the way to control which icon is displayed from those available in the sprite image.
Take a look at this discussion on Oracle community.

Adding Xamarin.Forms to an existing Xamarin app

I'm trying to add a Xamarin.Forms page to an existing Xamarin Android app.
I'm struggling to figure out how to mix native Xamarin Android pages and Xamarin.Forms pages.
All the articles and examples I have seen describe either Forms or Xamarin apps and not a hybrid of the two.
The best idea I have read about so far is to add a native stub and replace the content with Xamarin.Forms content but I'm not sure how to achieve this.
Update
I'm using MvvmCross so my android view is inherited from MvxActivity. I have a StackLayout containing views using Xamarin.Forms. How do I get XF to convert to android code so I can use with SetContentView?
When you create a new Xamarin.Forms project, for instance with a SharedProject approach, it will create the launcher project and initial class file that will be executed for you for each platform.
For instance on Android this is in MainActivity.cs. If you look inside this file you will notice that it inherits from AndroidActivity which in turn inherits from Activity, which is the typical class used on activities.
So you have two options available for you to create a mixed hybrid solution:-
1) Inherit from AndroidActivity in your platform-specifc stub-page should you want to display Xamarin.Forms content, or alternatively
2) Inherit from Activity, and do the same as usual.
If you want to display a Xamarin.Forms page from the stub-page you can then just use some boiler-plate code such as the following in the OnCreate method:-
SetPage({some class that returns a Xamarin.Forms.Page object, i.e. ContentPage});
You can then use the normal navigation that is specific to Android to either display a Xamarin.Forms page or a platform-specific Activity page.

Resources