我有一个oxyplot RectangleBarSeries和一个按钮“ Reset”。当我按下按钮时,我想重置变焦(以相同的方式,当在键盘上按A时,变焦会重置)。
我试图通过在MainPanel.xaml.cs中添加带有以下代码的事件处理程序来实现此目的:
private void Reset_Click(object sender, RoutedEventArgs e)
{
histogram.PlotModel.Axes[0].Reset();
histogram.PlotModel.Axes[1].Reset();
}
但出现错误“ myNameSpace.Histogram不包含PlotModel的定义,并且找不到扩展方法“ PlotModel”,该扩展方法接受类型为myNameSpace.Histogram的第一个参数”。
我应该写些什么才能重置绘图的缩放比例?
我的直方图课程的一部分:
namespace myNameSpace
{
public class Histogram : INotifyPropertyChanged
{
public Collection<Item> Items { get; set; }
private PlotModel histogramModel;
public PlotModel HistogramModel
{
get { return histogramModel; }
set { histogramModel = value; OnPropertyChanged("HistogramModel"); }
}
public class Item
{
public string Label { get; set; }
public double Value { get; set; }
}
public event PropertyChangedEventHandler PropertyChanged;
//NotifyPropertyChangedInvocator
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
public Histogram(List<double> frequency, List<double> axis, string VariableName)
{
CreateRectangleBar(frequency, axis, VariableName);
}
参考方案
尝试使用MyPlotViewName.ResetAllAxes();而是应该起作用。
WPF WebBrowser甚至使用ObjectForScripting在单独的线程上锁定UI - javascript在与WPF Web浏览器控件绑定的ObjectForScripting上调用方法时,网页UI锁定会出现一个奇怪的问题。进一步的研究使我们意识到整个UI(包括WPF应用程序而不是WebBrowser)都已锁定。使用的技术是带有Caliburn.Micro和Autofac的WPF。我在COM可见类上使用方法来推送到Caliburn.Micro提供的事件聚合器。进…
WPF MVVM中的动态TabControl - c#我几周前开始使用WPF(在C#中),现在我需要一些高级帮助来使用tabcontrol。首先,我正在使用MVVM(模型视图ViewModel)模式来设计我的应用程序,并且我有一个约束,即试图不要在文件(初始化xaml文件)后面的代码中添加代码。现在,我的问题是在MainWindow视图(窗口)中动态创建新的tabItem,当单击按钮(例如“新建选项卡”按钮)时…
WPF-将窗口大小设置为子用户控件大小 - c#我有一个选项卡控件,该控件动态地填充有包含各种大小的用户控件的选项卡。打开选项卡后,我希望窗口自动调整大小,使其在活动用户控件下有意义。有一种干净的方法可以做到这一点吗?我正在使用标准的mvvm模式。 参考方案 在Window类上使用SizeToContent属性。<Window x:Class="WpfApplication1.MainWi…
获取ListBoxItem的索引-WPF - c#如何获取ListBoxItem的索引?ListBox通过XmlDataProvider绑定到XML节点的集合。 参考方案 我有一个类似的问题,得到了回答here基本上,您将ListBox的AlternationCount设置为非常高的值,并绑定到每个项目上的AlternationIndex<ListBox AlternationCount="…
在datagrid(wpf)中选择行索引 - c#如何在datagrid中选择行索引? 事件SelectionChanged以下代码不起作用: private DataGridRow dgr = new DataGridRow(); private void dataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { thi…