Sparkline for UWP
手順2:コードの追加
クイックスタート > 手順2:コードの追加

In this step, you will add code to specify the data to which the C1Sparkline control is bound.

  1. MainPage.xaml を右クリックし、リストから[コードの表示]を選択します。
  2. 次のコードを InitializeComponent() メソッドの下に追加して、マーカーの色を変更し、C1Sparkline コントロールのデータを作成します。

    コードのコピー
    sparkline.MarkersColor = Colors.DeepPink;
     
    List<double> data = new List<double>() { 1, -2, 3, 4};
                Sale = new Sales();
                Sale.Data = data;
               
                List<DateTime> dateTime = new List<DateTime>() { new DateTime(2013,11,1), new DateTime(2013,11,2), new
    DateTime(2013,11,4), new DateTime(2013,10,5) }; Sale.DateAxis = dateTime; this.sparkline.DataContext = Sale;
  3. 次に、手順2で追加したコードの下に、次のクラスを追加します。

    コードのコピー
    public Sales Sale { get; set; }
    }
    
  4. 次のコードを追加して、スパークラインにデータを挿入します。

    コードのコピー
    public class Sales
        {
            public List<double> Data{get;set;}
            public List<DateTime> DateAxis{get;set;}
     
            public Sales()
            {
                Data = new List<double>();
                DateAxis = new List<DateTime>();
            }
        }
    
関連トピック