locked
OnPlatform in NavigationPage using XAML RRS feed

  • Question

  • User332065 posted

    Given this original code, I'm trying to hide the icon on Android:

        <NavigationPage Title="Page" Icon="page_icon.png">
            <x:Arguments>
                <views:MyPage />
            </x:Arguments>
        </NavigationPage> 
    

    I have attempted to use OnPlatform many different ways and cannot get it to work. Here are some things I have tried:

    <NavigationPage Title="Page">          
        <NavigationPage.Icon>     
            <OnPlatform x:TypeArguments="x:String">     
                <OnPlatform.iOS>page_icon.png</OnPlatform.iOS> 
                <OnPlatform.Android>{x:Null}</OnPlatform.Android>    
            </OnPlatform>    
        </NavigationPage.Icon>     
        <x:Arguments>
            <views:MyPage />
        </x:Arguments>
    </NavigationPage> 
    

    This produced the error: "The given key was not present in the dictionary." I also tried this:

    <NavigationPage Title="Rater">
        <OnPlatform 
            x:Key="Icon"
            x:TypeArguments="x:String" 
            iOS="tab_feed.png"
            Android="{x:Null}"
        />
        <x:Arguments>
            <views:MyPage />
        </x:Arguments>
    </NavigationPage>
    

    Which runs, but no icons show up on iOS.

    Help please???

    Friday, June 23, 2017 11:13 PM

Answers

  • User332065 posted

    Solution is as follows:

                <NavigationPage.Icon>
                    <OnPlatform x:Key="SwitchOnIcon" x:TypeArguments="FileImageSource">
                        <On Platform="iOS">tab_feed.png</On>
                    </OnPlatform>
                </NavigationPage.Icon>  
    
    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Saturday, June 24, 2017 4:41 PM