2014-02-20 52 views

回答

2
<StackPanel> 
    <Ellipse x:Name="ell" Width="50" Height="50"> 
     <Ellipse.Fill> 
      <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> 
       <GradientStop Color="Black" Offset="0"/> 
       <GradientStop x:Name="stopToBind" Color="#FFFF0808" Offset="1"/> 
      </LinearGradientBrush> 
     </Ellipse.Fill> 
    </Ellipse> 

    <Slider Value="{Binding ElementName=stopToBind, Path=Offset, Mode=TwoWay}"/> 
</StackPanel> 

UPDATE

不順利:

<StackPanel> 
    <Ellipse x:Name="ell" Width="50" Height="50"> 
     <Ellipse.Fill> 
      <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> 
       <GradientStop Color="Red" Offset="{Binding ElementName=sl, Path=Value, Mode=TwoWay}"/> 
       <GradientStop Color="Black" Offset="{Binding ElementName=sl, Path=Value, Mode=TwoWay}"/> 
      </LinearGradientBrush> 
     </Ellipse.Fill> 

    </Ellipse> 

    <Slider Value="0.5" x:Name="sl" Maximum="1" Minimum="0"/> 
</StackPanel> 
+0

非常感謝您的快速回復,但我需要顏色之間的邊界不會模糊 – XmaksasX

+0

請參閱我的更新。 :) –

+0

非常感謝!還有一個問題,我可以通過代碼管理它,而不使用滑塊,通過變量? – XmaksasX