2012-05-07 19 views
1

WPFアプリケーションの新機能です。WPFアプリケーションを読み取るセンサーで作業しています。このアプリケーションでは、170個のセンサーの中からセンサーを選択する必要があります。レポートを表示すると、グラフプロッタが選択したセンサのグラフを描画します。凡例ボックス(ChartPlotter)に垂直スクロールを追加WPF

問題:

ここ起因するページのサイズ制限に私は、センサの数がグラフの高さ以上の場合、選択したセンサーの伝説に調整されていない人々を隠すgraph.Butの高さを固定していますグラフの高さ。どのように私は凡例のボックスにスクロールを追加できるので、ユーザーはすべてのセンサーの凡例をスクロールしてチェックすることができます。

いくつか考えてください。

ありがとうございます。

答えて

1

私はこの問題についてウェブで多くを検索しましたが、私はこの問題を解決するための解決策はありませんでした。この問題を解決するために、私はこれらの手順に従います。

1.最初にプロッターの凡例の表示を偽にする plotter.LegendVisible = false;

2.)次に、プロッタの凡例が表示されたグラフにリストビューコントロールを正確に追加します。

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; 

-Add ItemVM.cs -

<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.)それから私は、バックエンドでいくつかの作業を行います

スクロールしてチャートプロッタで凡例ボックスを取得し、forecolorを再調整してチャートの線色を反映させました。

0

は、ScrollViewerのを使用します。

<ScrollViewer Height="whatever your graph height is"> 
    <ListView> 
      ...Dynamically place all your sensors here from your Presenter or code-behind 
    </ListView> 
</ScrollViewer> 

これはあなたのためにそれの世話をする必要があります。

+1

あなたのレスポンスに感謝します.DynamicDataDisplayアセンブリをWPFで使用したことがありますか? – Sunny

+0

以前はDynamicDataDisplayを使用していませんでした。 – Curtis

+0

私の答えを確認してください私はそれを解決しました:-) – Sunny

関連する問題