<MultiBinding Converter="{StaticResource DifferenceConverter}">
<Binding Path="[1].Value" />
<Binding Path="[0].Value" />
</MultiBinding>
I have list List<List<KeyValuePair<string, int>>>
which i bind to DataContext
of WPF Toolkit chart.
Every item in list - new ColumnSerie
and binding I try to apply only to last serie
What i need - correctly use MultiBinding (Don't know how to write correct path to values of first and second items in list).
Also tried smth like [1]/Value
- unsuccess.
UPDATE (Detailed Explanation):
As i wrote before, i have chart with few columnSeries (really only 2).
I bind List<List<KeyValuePair<string, int>>>
(size = 2) to chart DataContext
and in XAML init ColumnSeries like ItemsSource="{Binding [1]}"
For Second ColumnSeries I create Style :
<Style x:Key="ColumnDataPointStyle1" TargetType="{x:Type chartingToolkit:ColumnDataPoint}">
<Setter Property="Background" Value="#61596f" />
<Setter Property="BorderBrush" Value="#61596f" />
<Setter Property="BorderThickness" Value="100" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Padding" Value="0" />
<Setter Property="Margin" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type chartingToolkit:ColumnDataPoint}">
<Grid>
<Rectangle Fill="{TemplateBinding Background}" />
<TextBlock Foreground="White" FontSize="8" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock.Text>
<MultiBinding Converter="{StaticResource DifferenceConverter}">
<Binding ElementName="FirstScan" Path="ItemsSource[0].Value"/>
<Binding Path="Value" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
And Converter :
public class DifferenceConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
var diff = (int) values[1] - (int) values[0];
if (diff > 0)
{
return "<";
}
if (diff < 0)
{
return ">";
}
return "none";
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
This converter should show difference between column value in first and second series. If first value is greater than second - ">" else "<", if Equal - "none" etc. Problem - need to bind values from first ColumnSeries.