【问题标题】:OxyPlot in Xamarin Forms WPF project, how to change tracker text colorXamarin Forms WPF项目中的OxyPlot,如何更改跟踪器文本颜色
【发布时间】:2019-02-03 22:28:57
【问题描述】:

我在 Xamarin Forms 项目中使用 OxyPlot。

在 WPF 中,跟踪器(当我单击数据点时弹出)具有带有黄色文本的白色背景,因此无法看到。

然而,在 UWP 中,黄色背景和黑色文本就可以了。

如何将跟踪器的字体颜色更改为黑色?

xmlns:oxy="clr-namespace:OxyPlot.Xamarin.Forms;assembly=OxyPlot.Xamarin.Forms"
<oxy:PlotView Model="{Binding MyModel}"
              HorizontalOptions="FillAndExpand"
              VerticalOptions="FillAndExpand">
</oxy:PlotView>

【问题讨论】:

    标签: oxyplot


    【解决方案1】:

    您可以通过修改控制模板来更改 Oxyplot Tracker 的默认颜色。例如,

     <oxy:PlotView Height="500" Width="500" Model="{Binding MyModel}">
                <oxy:PlotView.DefaultTrackerTemplate>
                    <ControlTemplate>
                        <oxy:TrackerControl Position="{Binding Position}" LineExtents="{Binding PlotModel.PlotArea}">
                            <oxy:TrackerControl.Background>
                                <SolidColorBrush Color="LightBlue" />
                            </oxy:TrackerControl.Background>
                            <oxy:TrackerControl.Content>
                                <TextBlock Text="{Binding}" Margin="7" Foreground="Black" />
                            </oxy:TrackerControl.Content>
                        </oxy:TrackerControl>
                    </ControlTemplate>
                </oxy:PlotView.DefaultTrackerTemplate>
            </oxy:PlotView>
    

    当然,你也可以在上面设置绑定,但是为了举例,在上面的例子中直接给出颜色。

    【讨论】:

    • 谢谢,这给了我线索。我使用的是 Xamarin Forms 而不是本机 WPF。我已经编辑了我的问题以更好地反映这一点。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-15
    • 2020-03-26
    • 2022-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多