WP7 Action on App Bar Button

Oct 29, 2010 at 6:13 AM

Hi

How do I handle a click event on an ApplicationBarIconButton?

It doesn't seem to handle actions automatically like a button.

I can't do this:

    <shell:ApplicationBarIconButton
            x:Name="MeButton"
            IconUri="/Images/target.png"
            Text="Me"
            cal:Message.Attach="[Event Click] = [Action MeButtonClick]"
        >
    </shell:ApplicationBarIconButton>
    

as It tells me I can't attach to an app bar icon button.

Any ideas?

Cheers

Steve



Coordinator
Oct 30, 2010 at 7:54 AM

You need to use our built-in menu and button objects. Set the Message property on those and it will work. This is a limitation in WP7 so we have the custom work around for that.

Nov 1, 2010 at 3:29 AM

What is the name of the built in menu and button objects?

Nov 5, 2010 at 4:49 AM

Had a good look round but can't find the name of these controls. 

Can someone lt me know the name of them please.

Cheers

Steve

Nov 5, 2010 at 10:26 AM
Edited Nov 5, 2010 at 10:28 AM

I guess Rob meant something like:

 

        <phone:PhoneApplicationPage.ApplicationBar>
		<shell:ApplicationBar IsVisible="True">
			<shell:ApplicationBar.Buttons>
				<cal:AppBarButton IconUri="/Images/target.png"
				                  Text="Me"
				                  Message="MeButtonClick" />
			</shell:ApplicationBar.Buttons>
		</shell:ApplicationBar>
	</phone:PhoneApplicationPage.ApplicationBar>

 

See the CM+WP7 documentation here: http://caliburnmicro.codeplex.com/wikipage?title=Working%20with%20Windows%20Phone%207&referringTitle=Documentation

Nov 6, 2010 at 4:31 AM

Thanks Marco. Just what I was looking for.

Cheers

Steve