I searched a lot on web for this problem but i got no solution for this.So to solve this problem i follow these steps.
1.)first i make plotter legend visibility false by
plotter.LegendVisible = false;
2.)Second i add a listview control exactly on the graph where plotter Legend was appear.
<ListView Height="Auto" HorizontalAlignment="Center" Margin="1100,139,0,0" Name="listview" ItemsSource="{Binding Items}" HorizontalContentAlignment="Stretch" VerticalAlignment="Top" Width="75" Grid.RowSpan="2" MaxHeight="260">
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Text}" Foreground="{Binding BackgroundColor}">
</TextBlock>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.BorderBrush>
<SolidColorBrush />
</ListView.BorderBrush>
</ListView>
3.)Then i do some work on back end as -
-Add ItemVM.cs :
class ItemVM : INotifyPropertyChanged
{
private string TextValue = String.Empty;
private Brush BackgroundColorValue = null;
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String info)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}
public ItemVM(Brush color, string objectData)
{
BackgroundColor = color;
Text = objectData;
}
public string Text
{
get
{
return this.TextValue;
}
set
{
if (value != this.TextValue)
{
this.TextValue = value;
NotifyPropertyChanged("Text");
}
}
}
public Brush BackgroundColor
{
get
{
return this.BackgroundColorValue;
}
set
{
if (value != this.BackgroundColorValue)
{
this.BackgroundColorValue = value;
NotifyPropertyChanged("BackgroundColor");
}
}
}
}
-In mainform.xaml.cs :
List<ItemVM> Items;
List<string> lst = new List<string> {"item1","item2","item3" };
var converter = new System.Windows.Media.BrushConverter();
Color[] colors = ColorHelper.CreateRandomColors(3);
Items = new List<ItemVM>();
for(int i=0;i<lst.count;i++)
{
Items.Add(new ItemVM((Brush)converter.ConvertFromString(colors[i].ToString()), SelectedItems[i]));
}
plotter.LegendVisible = false;
listview.ItemsSource = Items;
Now i got legend box on chart plotter with scroll and regend forecolor also reflect chart line color.