2011-06-29 3 views
2

私は軸を通貨としてフォーマットすることはできません。DependentRangeAxisのコードAxisLabelでどのように書式設定しますか?

私は間違っていますか?私はその場で書式を変更できる必要があります。このテストでは、値のスケールでY軸の通貨として設定したかったのです。

誰でも?グラフ作成ツールキットの私のWPF4版で

var columnSeries = new ColumnSeries 
           { Title = reportProcedureNode.Value, 
            IndependentValuePath = "PrimaryKey", 
            DependentValuePath = "Value", 
            IndependentAxis = new CategoryAxis { Orientation = AxisOrientation.X, ShowGridLines = false, Location = AxisLocation.Bottom}, 
            DependentRangeAxis = new LinearAxis(){Orientation = AxisOrientation.Y, ShowGridLines = false} 
           }; 

     var labelStyle = new Style(typeof(AxisLabel)); 
     labelStyle.Setters.Add(new Setter(AxisLabel.StringFormatProperty, "{}{0:C0}")); 

     var axis = (LinearAxis)columnSeries.DependentRangeAxis; 
     axis.AxisLabelStyle = labelStyle; 

答えて

3

おかげで...、あなたのコードがクラッシュします。

labelStyle.Setters.Add(new Setter(AxisLabel.StringFormatProperty, "{}{0:C0}")); 

へ:

ある
labelStyle.Setters.Add(new Setter(AxisLabel.StringFormatProperty, "{0:C0}")); 

{}を削除する私は変更する必要がありました。 {}は、マークアップ拡張機能の構文から来ている:

"{...}"内部のマークアップ拡張機能としてXAMLによって解析されている場合にのみ必要とされています。

プロパティを直接設定しているため、マークアップ拡張機能は含まれていないため、実際の通貨フォーマットが表示されません。

+0

ありがとうございます。それがトリックでした。 – nitefrog

関連する問題