色が塗りつぶされる矩形が、RGBスライダからMultiBindingConverterによって決定されます。線分ブラシに矩形の塗りつぶしを行う
<Rectangle.Fill>
<SolidColorBrush>
<SolidColorBrush.Color>
<MultiBinding Converter="{StaticResource RgbConverter}">
<Binding Path="Value" ElementName="RSlider" />
<Binding Path="Value" ElementName="GSlider" />
<Binding Path="Value" ElementName="BSlider" />
</MultiBinding>
</SolidColorBrush.Color>
</SolidColorBrush>
</Rectangle.Fill>
今、私は私がたObjectDataProvider
ChosenColorは、拡張メソッドである<ObjectDataProvider ObjectInstance="{StaticResource ResourceKey=cColor}" MethodName="ChosenColor" x:Key="chColor" >
</ObjectDataProvider>
てみました色のGradientStop
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0" Color="Black" />
<GradientStop Offset="1" Color="{here bind the color}" />
</LinearGradientBrush>
</Rectangle.Fill>
"選択" というようにしたい:
public static Color ChosenColor(this Rectangle rect)
{
return ((SolidColorBrush)rect.Fill).Color;
}
を
は運がない。どうやってするか?
あなたはこれを単純化し、コンバータを使用しないことができるはずです。<のGradientStopは=「1」色=を "オフセット{のElementNameバインディング= rct、Path = Fill.Color} "/> – AndrewS
Thnx @AndrewS私は自分の答えを更新しました。そのコンバーターを書いているときに私が何を考えていたのか分かりません。 :) –
そのシンプルさのために:)素晴らしい仕事RV1987、ありがとう – deha