내 CustomNumericLabelProvider를 통해 viewModel의 배율 인수에 액세스하려고합니다.Custom Label Provider : Init() 메서드를 재정의 할 수 없습니다.
내가 가장 좋은 방법이 무엇인지 확실히 모르겠지만, 내가 LabelProvider에 표시 된 초기화 (IAxis parentAxis) 방법을 사용하면 내가 부모 축을 통해 액세스 할 수 있습니다 생각 documentation. 나는 그것을 시도했지만, 지금은 오류가 발생했습니다. "오버라이드를위한 적절한 방법이 없습니다".
Init() 메서드를 주석 처리하면 CustomNumericLabelProvider는 훌륭하게 (하드 코드 된 배율 인수로) 작동합니다.
이 오류 메시지가 표시되는 이유는 무엇입니까? 또는 내 viewModel의 배율 인수에 액세스하는 것이 다른 좋은 접근 방법일까요?
참고 : 나는 viewModel을 레이블 공급자의 사용자 지정 생성자 (viewportManager에서 이와 비슷한 작업을 수행 할 수 있음)로 전달하려고했지만 작동하지 않는 것 같습니다. 여기
코드입니다 (사용자 정의 생성자와 나는 그것을하지 않고 같은 오류 메시지가 있지만)public class CustomNumericLabelProvider : SciChart.Charting.Visuals.Axes.LabelProviders.NumericLabelProvider
{
// Optional: called when the label provider is attached to the axis
public override void Init(IAxis parentAxis) {
// here you can keep a reference to the axis. We assume there is a 1:1 relation
// between Axis and LabelProviders
base.Init(parentAxis);
}
/// <summary>
/// Formats a label for the axis from the specified data-value passed in
/// </summary>
/// <param name="dataValue">The data-value to format</param>
/// <returns>
/// The formatted label string
/// </returns>
public override string FormatLabel(IComparable dataValue)
{
// Note: Implement as you wish, converting Data-Value to string
var converted = (double)dataValue * .001 //TODO: Use scaling factor from viewModel
return converted.ToString();
// NOTES:
// dataValue is always a double.
// For a NumericAxis this is the double-representation of the data
}
}
필자는 하드 코딩 된 여러 개의 레이블 제공 업체를 생성하여이 문제를 즉시 해결할 수있었습니다. 이것은 잘 작동하는 것 같지만 올바른 접근 방법인지는 확실치 않습니다. 또한 각각의 ** Init() ** 메소드를 주석 처리해야했습니다. 여기에 뭔가 빠져 있어야합니다. :) –