简体   繁体   中英

application bar icon button over rides original designer windows phone

im using following code for showing application bar in wp app

<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" Mode="Minimized" BackgroundColor="#FF3E5F99">
            <shell:ApplicationBarIconButton IconUri="/Assets/fb.png" Text="Facebook"  Click="btnFB_onClick" IsEnabled="True"/>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

it shows correct icon button in designer but the problem is, if i run the app it shows X as icon button instead of F Facebook icon button

You need to set UriKind to Relative / RelativeOrAbsolute I suggest to use following code on Page Load event

ApplicationBar appBar = new ApplicationBar();
appBar.Mode = ApplicationBarMode.Minimized;
appBar.IsMenuEnabled = true;
appBar.IsVisible = true;
appBar.BackgroundColor = Color.FromArgb(120, 0,229,249)

ApplicationBarIconButton button = new ApplicationBarIconButton();
button.IconUri = new Uri("/Assets/fb.png", UriKind.Relative);
button.Text = "Facebook";
button.Click += btnFB_onClick(null, null);
button.IsEnabled = true;
appBar.Add(button);

If it shows up in Designer View and not runtime it is usually because it is deployed incorrectly.

Check to see if the file in the Assets Folder has a Build Action of Content like below (just click on the file in Visual Studio Solution Explorer)

在此处输入图片说明


If the file is not in the Assets Folder then Right click on the Assets Folder -> Add Existing Item

@Marek problem is not solved even after i made your suggestions though.

i changed to generic share icon it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM