使用MultiBindingの:multiBindingConverterスケール上の矩形の位置、その高さ、。
例:
<Window.Resources>
<c:NameConverter x:Key="myNameConverter"/>
...
</Window.Resources>
...
<Rectangle Name="myRectangle" DataContext="myDataContext">
<Rectangle.Fill>
<MultiBinding Converter="{StaticResource myGradientConverter}">
<Binding Path="PositionOnScale"/>
<Binding Path="Height"/>
</MultiBinding>
</Rectangle.Fill>
</Rectangle >
その後:
public class myGradientConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
... // do stuff here to return the corresponding Gradient
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
... // do stuff here (optional)
}
}