项目-WPF,C#,IDE-Visual Studio。我想在我的PlotView上进行绑定(bind)值跟踪。我的代码XAML:
<Border CornerRadius="6" BorderBrush="Gray" BorderThickness="4" Grid.Column="0" Grid.ColumnSpan="2">
<oxy:PlotView Background="White" Model="{Binding GraphicModel.Model}" >
</oxy:PlotView>
</Border>
<TextBlock Text="{Binding CurrentTrackerValue}" Grid.Column="0" Grid.Row="1"/>
我知道,什么PlotView.Model都有事件TrackerChange。如何使用此事件?
附注:我使用模式MVVM,所以我想使用命令代替事件。谢!
最佳答案
如果我正确理解您的要求,则每次跟踪器更新时都希望更新一个TextBlock。我相信您在TrackerChanged事件上正步入正轨。您可以在要创建PlotModel实例的ViewModel中执行以下操作,该实例将绑定(bind)到OxyPlot Graph
PlotModelName.TrackerChanged += (sender, eventArgs)=>
{
CurrentTrackerValue = eventArgs.HitResult != null ? eventArgs.HitResult.Text : CurrentTrackerValue;
NotifyPropertyChanged(nameof(CurrentTrackerValue));
};
其中CurrentTrackerValue定义为
public string CurrentTrackerValue { get; set; }
这样可以确保每次通过TrackerChangedEvent更改跟踪器时,都会更新CurrentTrackerValue属性
关于c# - 绑定(bind)OxyPlot Tracker并在TextBlock中设置获取值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54636770/