gpt4 book ai didi

wpf - 如何在 XAML 中将颜色转换为画笔?

转载 作者:行者123 更新时间:2023-12-03 05:29:21 25 4
gpt4 key购买 nike

我想将 System.Windows.Media.Color 值转换为 System.Windows.Media.Brush。颜色值数据绑定(bind)到 Rectangle 对象的 Fill 属性。 Fill 属性采用 Brush 对象,因此我需要一个 IValueConverter 对象来执行转换。

WPF 中有内置转换器还是我需要创建自己的转换器?如果有必要,我该如何创建自己的?

最佳答案

我知道我参加聚会真的迟到了,但你不需要转换器。

你可以做

<Rectangle>
<Rectangle.Fill>
<SolidColorBrush Color="{Binding YourColorProperty}" />
</Rectangle.Fill>
</Rectangle>

关于wpf - 如何在 XAML 中将颜色转换为画笔?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3309709/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com