相关疑难解决方法(0)

在XAML中设置WPF OxyPlot PlotViews的样式

设置OxyPlot绘图视图时,您可以通过各种控件显式定义绘图,也可以通过绑定到a来设置PlotModel.

因此,在第一种情况下,两个LineSeries对象的绘图的XAML 可能看起来像

<oxy:Plot Title="Some plot">
    <oxy:Plot.Axes>
        <oxy:LinearAxis Position="Left" />
        <oxy:LinearAxis Position="Bottom" />
    </oxy:Plot.Axes>
    <oxy:Plot.Series>
        <oxy:LineSeries ItemsSource="{Binding ActualSeriesData1}" DataFieldX="X" DataFieldY="Y"/>
        <oxy:LineSeries ItemsSource="{Binding ActualSeriesData2}" DataFieldX="X" DataFieldY="Y"/>
    </oxy:Plot.Series>
</oxy:Plot>
Run Code Online (Sandbox Code Playgroud)

具有非常薄的视图模型.另一方面,在第二种情况下,我只会有类似的东西

<oxy:PlotView Model="{Binding SomePlotModel}" />
Run Code Online (Sandbox Code Playgroud)

并在视图模型中构建实际的图.两种设置都有利有弊,但我发现第一种方法通常在我事先知道我想要绘制的内容时效果更好,而第二种方法允许对绘图内容进行动态更改.

我的问题如下:对于第一种情况,我知道如何为所有图添加一般样式.例如,如果我想让它们看起来像Seaborn,我会添加类似的东西

<x:Array Type="Color" x:Key="SeabornColors">
    <Color>#4c72b0</Color>
    <Color>#55a868</Color>
    <Color>#c44e52</Color>
    <Color>#8172b2</Color>
    <Color>#ccb974</Color>
    <Color>#64b5cd</Color>
</x:Array>
<Style TargetType="oxy:Plot">
    <Setter Property="PlotAreaBackground" Value="#EBEBF2" />
    <Setter Property="PlotAreaBorderThickness" Value="0" />
    <Setter Property="TitleFont" Value="Segoe UI" />
    <Setter Property="TitleFontWeight" Value="Normal" />
    <Setter Property="DefaultColors" Value="{StaticResource SeabornColors}"/>
</Style>
<Style TargetType="oxy:LinearAxis">
    <Setter Property="TicklineColor" Value="White" />
    <Setter Property="MajorGridlineColor" …
Run Code Online (Sandbox Code Playgroud)

.net c# wpf xaml oxyplot

6
推荐指数
1
解决办法
2094
查看次数

OxyPlot中的多个LineSeries绑定

是否可以将绘图绑定到LineSeries集合而不是OxyPlot中的单个LineSeries?(而不是通过模型).

我正在寻找这样的东西:

<oxy:Plot>        
    <oxy:Plot.Series>     
        <oxy:LineSeries ItemsSource="{Binding myCollectionOfLineSeries}" />              
    </oxy:Plot.Series>
</oxy:Plot>
Run Code Online (Sandbox Code Playgroud)

myCollectionOfLineSeries的位置是:

private ObservableCollection<LineSeries> _myCollectionOfLineSeries ;
        public ObservableCollection<LineSeries> myCollectionOfLineSeries 
        {
            get
            {
                return _myCollectionOfLineSeries ;
            }
            set
            {
                _myCollectionOfLineSeries = value;
                OnPropertyChanged("myCollectionOfLineSeries ");

            }
        }
Run Code Online (Sandbox Code Playgroud)

我希望得到答案:a)"不,这是不可能的"或b)"是的,只是把XYZ放在IJK之前".

谢谢阅读.

c# wpf plot oxyplot

5
推荐指数
2
解决办法
9706
查看次数

标签 统计

c# ×2

oxyplot ×2

wpf ×2

.net ×1

plot ×1

xaml ×1