我正在尝试在windows 8移动应用程序中动态更改按钮的背景颜色。
来自Mainpage.xaml:
<Button Name="RedButton" Click="RedButton_Click_1" Width="200" Height="100" Content="Red" Margin="136,171,144,497"/>
来自mainpage . example .cs的代码
Dispatcher.BeginInvoke(delegate()
{
RedButton.Background = new SolidColorBrush(Colors.Red);
});
代码根本没有修改红色按钮对象的背景。是什么导致了这个通信?
为什么不从xaml文件中更改颜色而不是从类中更改呢?您也可以使用属性窗口来更改属性。
Background="Colour"
Foreground="Colour"
BorderBrush="Colour"