为什么Button的颜色不变?

swdmike 2010-02-27 10:15:07
WPF里:

<StackPanel TextBlock.Foreground="Red" TextBlock.FontSize="24">
<TextBlock>Just A TextBlock</TextBlock>
<Button>Just A Button</Button>
</StackPanel>
...全文
188 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Goldfire_001 2010-02-28
  • 打赏
  • 举报
回复
这个么。

原因应该是这样。

Button的ForegroundProperty

ForegroundProperty = TextElement.ForegroundProperty.AddOwner(typeof(Control), new FrameworkPropertyMetadata(SystemColors.ControlTextBrush, FrameworkPropertyMetadataOptions.Inherits));


TextBlock的ForegroundProperty

ForegroundProperty = TextElement.ForegroundProperty.AddOwner(typeof(TextBlock));


所以呢。Type不一样啊。换TextElement试一下。
rdsnow 2010-02-28
  • 打赏
  • 举报
回复
貌似 Button 的前景色要另外设置的吧,什么原因我不知道啦。

        <StackPanel TextBlock.Foreground="Red" TextBlock.FontSize="24">
<TextBlock>Just A TextBlock</TextBlock>
<Button Foreground="Red">Just A Button</Button>
</StackPanel>

8,744

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧