Я искал много в Интернете для этой проблемы, но у меня нет решения для этого. Поэтому для решения этой проблемы я выполняю следующие действия.
1.) сначала я создаю видимость легенды плотника false plotter.LegendVisible = false;
2.) Во-вторых, я добавляю элемент управления listview точно на графике, где появился плоттер Legend.
<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.) Тогда я сделать некоторую работу на задней части, как -
-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");
}
}
}
}
-В 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;
Теперь у меня есть поле для показа на графическом плоттере с прокруткой и регенерация forecolor, также отражают цвет линии диаграммы.
спасибо за ваш ответ. Вы когда-нибудь использовали сборку DynamicDataDisplay в WPF? – Sunny
nope. никогда ранее не использовался DynamicDataDisplay. – Curtis
проверить мой ответ, я решил это :-) – Sunny