开发者

WP7 - can't change button's properties/styles on click

开发者 https://www.devze.com 2023-01-27 06:12 出处:网络
I am working on a Window开发者_JAVA技巧s Phone 7 app, and trying to change some of the properties/styles of a button when it is clicked.

I am working on a Window开发者_JAVA技巧s Phone 7 app, and trying to change some of the properties/styles of a button when it is clicked.

I can change the Content with no problem, but I cannot change certain visual styles (background, font color, etc). Strangely, I am able to change OTHER button styles during the click event.

Ideas why? I've seen this thread which looks related, but not exactly what I'm trying to accomplish (not programmatic changes, but styling): Windows Phone 7 (WP7) Change a button's background color on click

private void pbMood_Click(object sender, RoutedEventArgs e)
{
    AppMoods.NextMood();
    pbMood.Content = AppMoods.CurrentMoodName;
    SolidColorBrush sBrush = (SolidColorBrush)pbMood.Background;
    pbMood.Background = GetColorFromHexa(AppMoods.CurrentMoodColor);        // NO WORK
    pbFavorites.Background = GetColorFromHexa(AppMoods.CurrentMoodColor);   // WORK
}


I suspect the properties you're trying to change are visual styles affected by the button state. Peter Torr wrote about just such an issue:

Why can't I change the Background of my Button on a Click event?

0

精彩评论

暂无评论...
验证码 换一张
取 消