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

Problem binding icon to ToolbarItem

$
0
0

Hi,

I have view built in Xaml and a viewmodel tied to the views bindingcontext. In my viewmodel I have an attribute containing the image path I'd like to have on a ToolbarItem.
Xaml:

<ContentPage.ToolbarItems>
    <ToolbarItem Name="Summering" Icon="{Binding SumListIcon}" Order="Primary" Command="{Binding ToggleListsCommand}"/>
    </ContentPage.ToolbarItems>

ViewModel:

public string SumListIcon {
                get {
                    return ShowList ? "sigma.png" : "list.png";
                }
            }

When opening this view in the app I get an exception telling me "Xamarin.Forms.Xaml.XamlParseException: No Property of name Icon found". If I change the Icon attribute to a string instead of a binding it works.
I've also tried using ImageSource instead of string with same result.
Shouldn't it be possible to bind the icon?

Regards


Viewing all articles
Browse latest Browse all 77050

Trending Articles



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