Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

ToolbarItem Icon EmbeddedResource

$
0
0

Hello,

i'm trying to add a ToolbarItem to a NavigationPage. This ToolbarItem should have an Icon from an EmbeddedResource-Image.
I made an fresh Xamarin.Forms MasterDetail Project and added the image, ImageResourceExtension and the ToolbarItems code in the XAML file like this:

<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns:views="clr-namespace:App1.Views"
            xmlns:local="clr-namespace:App1"
            x:Class="App1.Views.MainPage">
    <TabbedPage.Children>
        <NavigationPage Title="Browse">

            <NavigationPage.ToolbarItems>
                <ToolbarItem Text="Here has to be a logo" Icon="{local:ImageResource Source=App1.home.png}" />
            </NavigationPage.ToolbarItems>

        </NavigationPage>      
    </TabbedPage.Children>
</TabbedPage>
 [ContentProperty(nameof(Source))]
    public class ImageResourceExtension : IMarkupExtension
    {
        public string Source { get; set; }

        public object ProvideValue(IServiceProvider serviceProvider)
        {
            if (this.Source == null)
            {
                return null;
            }

            var imageSource = FileImageSource.FromResource(this.Source);

            return imageSource;
        }
    }

Do someone give me a hint why the image is not displayed?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>