You have to access the button like this:
var applicationBarIconButton = ApplicationBar.Buttons[0] as ApplicationBarIconButton;
if (applicationBarIconButton != null)
{
//do stuff
}
The index depending on where it is located in the appbar.
Question
Well then , I got something like this in my manipange.xaml , my application bar declaration, and my button declaration/definition
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar x:Name="xxxx" IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton
x:Name="appBarRegisterButton"
IconUri="/Images/next.png"
Text="Login"
Click="appBarRegisterButton_Click_1" IsEnabled="True"/>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
when i try to change some property from some other model, fe. this is my registartion Model.
public RegisterViewModel()
{
RegisterTitle = Resources.AppResources.RegisterTitle;
Messenger.Default.Register<RegisterButtonPressed>(this, msg => AttemptToRegister(msg.reg));
}
private void AttemptToRegister(Register reg)
{
reg.appBarRegisterButton.IsEnabled = true;
}
It does not change,better my register button is a null object, anyone got a point how to solve this? ;/
Solution
You have to access the button like this:
var applicationBarIconButton = ApplicationBar.Buttons[0] as ApplicationBarIconButton;
if (applicationBarIconButton != null)
{
//do stuff
}
The index depending on where it is located in the appbar.