如何更改 wpf 中按钮的内容 "color"
How can I change the content "color" of a button in wpf
<StackPanel Margin="2">
<Button Name="btn" Click="btn_Click" Content="Load Profile Image">
<Button.Background>
<ImageBrush ImageSource="D:\Pictures\rectangles.jpg"></ImageBrush>
</Button.Background>
</Button>
</StackPanel>
我在这里粘贴的图片几乎是黑色的,所以我想将内容颜色更改为白色,这样它才能正确显示。
抱歉,我没有在用逗号引用的标题中添加颜色,请原谅我的错误。现在好了,我想现在就清楚了reader ;)
我不认为我们理解你在这里想要什么,因为当你提供图像作为背景时它会变成背景。
如果你想要按钮的图像、文本和背景,试试这个
<Button Name="btn" Background="Red">
<Button.Content>
<Grid>
<Image Source="D:\Pictures\rectangles.jpg"></Image>
<TextBlock Text="Load Profile Image" ></TextBlock>
</Grid>
</Button.Content>
</Button>
假设您正在谈论要显示的文本的颜色,您需要 Foreground
属性.
<Button Name="btn" Click="btn_Click" Content="Load Profile Image" Foreground="White">
如果您想更改按钮的背景和前景,请执行此操作
<Button Name="btn" Content="Load Profile Image">
<Button.Background>
<ImageBrush ImageSource="D:\Pictures\rectangles.jpg"></ImageBrush>
</Button.Background>
<Button.Foreground>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1" >
<GradientStop Color="YellowGreen" Offset="0.25" />
<GradientStop Color="WhiteSmoke" Offset="1.5" />
</LinearGradientBrush>
</Button.Foreground>
</Button>
<StackPanel Margin="2">
<Button Name="btn" Click="btn_Click" Content="Load Profile Image">
<Button.Background>
<ImageBrush ImageSource="D:\Pictures\rectangles.jpg"></ImageBrush>
</Button.Background>
</Button>
</StackPanel>
我在这里粘贴的图片几乎是黑色的,所以我想将内容颜色更改为白色,这样它才能正确显示。
抱歉,我没有在用逗号引用的标题中添加颜色,请原谅我的错误。现在好了,我想现在就清楚了reader ;)
我不认为我们理解你在这里想要什么,因为当你提供图像作为背景时它会变成背景。
如果你想要按钮的图像、文本和背景,试试这个
<Button Name="btn" Background="Red">
<Button.Content>
<Grid>
<Image Source="D:\Pictures\rectangles.jpg"></Image>
<TextBlock Text="Load Profile Image" ></TextBlock>
</Grid>
</Button.Content>
</Button>
假设您正在谈论要显示的文本的颜色,您需要 Foreground
属性.
<Button Name="btn" Click="btn_Click" Content="Load Profile Image" Foreground="White">
如果您想更改按钮的背景和前景,请执行此操作
<Button Name="btn" Content="Load Profile Image">
<Button.Background>
<ImageBrush ImageSource="D:\Pictures\rectangles.jpg"></ImageBrush>
</Button.Background>
<Button.Foreground>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1" >
<GradientStop Color="YellowGreen" Offset="0.25" />
<GradientStop Color="WhiteSmoke" Offset="1.5" />
</LinearGradientBrush>
</Button.Foreground>
</Button>