oxyplot - Xamarin Forms WPF项目中的OxyPlot,如何更改跟踪器文本颜色
问题描述
我在 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 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>
当然,您也可以在上面设置绑定,但为了举例,在上面的示例中直接给出颜色。
推荐阅读
- java - 无法在 android 中创建我的视图模型类的实例
- javascript - 用于检测浏览器外部链接的 Google Chrome 扩展程序
- python - 如何更有效地解码 RSA 加密?
- c - 调用另一个函数并使其直接返回给该函数的调用者
- r - 将 Excel 文件中的表抓取到 R 中
- r - 如何分隔从 Excel 电子表格导入的列以创建多个单独的列表
- php - 从收藏夹中删除产品时出错(我自己创建了愿望清单系统)
- google-app-engine - 如何在 gcp 上部署 angular-spring-postgres 应用程序?
- openapi - OpenAPI - 参数名称值可以包含“>”字符吗?
- excel - VBA switch 语句(或字典)根据第一个字符填充相邻单元格中的值