0

我在我的 Windows 手机应用程序中有一个包含 2 个 appbariconbutton 的 applicationBar:

 <phone:PhoneApplicationPage.ApplicationBar>
    <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
        <shell:ApplicationBarIconButton x:Name="appbar_button1" IconUri="/Images/appbar_im1_selected.png" Text="im1" Click="appbar_button1_Click" />
        <shell:ApplicationBarIconButton x:Name="appbar_button2" IconUri="/Images/appbar_im2.png" Text="im2" Click="appbar_button2_Click" />

    </shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>

我需要像这样更改 2 appbariconbutton 的 iconUri

    private void appbar_button1_Click(object sender, EventArgs e)
        {
          //Switch the iconuri of appbar_button1 from /Images/appbar_im1_selected.png to /Images/appbar_im1.png
//Switch the iconuri of appbar_button2 from /Images/appbar_im2.png to /Images/appbar_im1_selected.png
        }

请问这个怎么做?

4

1 回答 1

2

只需更改图标的 IconUri

private void appbar_button1_Click(object sender, EventArgs e)
{
    ((ApplicationBarIconButton)this.ApplicationBar.Buttons[0]).IconUri = new Uri("/Images/appbar_im1.png", UriKind.Relative);
    ((ApplicationBarIconButton)this.ApplicationBar.Buttons[1]).IconUri = new Uri("/Images/appbar_im1_selected.png", UriKind.Relative);
}
于 2013-01-24T10:50:13.820 回答