First test of a Windows Phone application
- by Maurizio Reginelli
I downloaded the Microsoft Visual Studio 2010 Express for Windows Phone and I wrote a simple application to make a first test of the emulator. In this application I have only a button with the property Content binded to a string called ButtonText and with the property Background binded to a SolidColorBrush named FillColor. I handled the Click event with this code:
void MyButton_Click(object sender, RoutedEventArgs e)
{
if (toggle == true)
{
ButtonText = "Blue";
FillColor = new SolidColorBrush(Colors.Blue);
}
else
{
ButtonText = "Red";
FillColor = new SolidColorBrush(Colors.Red);
}
toggle = !toggle;
}
Unfortunately this doesn't work. While the Content of the Button changes each time the button is pressed, I cannot say the same for the Background which remains at the same color.
Could you tell me what is wrong? Thank you.
I also post the XAML:
<Grid x:Name="ContentGrid" Grid.Row="1">
<Button Name="MyButton" Width="300" Height="300"
Content="{Binding Path=ButtonText}"
Background="{Binding Path=FillColor}" />
</Grid>