开发者

Databinding WPF Rectangle gradient fill

开发者 https://www.devze.com 2023-01-11 02:39 出处:网络
I\'m attempting to databind a gradient brush as a Rectangle fill. What do I need to do to get the commented-out binding to work?开发者_开发问答StartColor and EndColor are declared as System.Drawing.Co

I'm attempting to databind a gradient brush as a Rectangle fill. What do I need to do to get the commented-out binding to work? 开发者_开发问答StartColor and EndColor are declared as System.Drawing.Color.

<Rectangle Width="100" Height="20">
  <Rectangle.Fill>
    <LinearGradientBrush>
      <GradientStop Offset="0" Color="Pink"/>
      <GradientStop Offset="1"  Color="Red"/>
      <!--<GradientStop Offset="0" Color="{Binding Path=StartColor}"/>-->
      <!--<GradientStop Offset="1" Color="{Binding Path=EndColor}" />-->
    </LinearGradientBrush>
  </Rectangle.Fill>
</Rectangle>


The problem was using System.Drawing.Color rather than the proper System.Windows.Media.Color

0

精彩评论

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