jo phul
jo phul

Reputation: 647

OxyPlot in Xamarin Forms WPF project, how to change tracker text color

I'm using OxyPlot in a Xamarin Forms project.

In WPF, the tracker (popup when I click on a datapoint) has a white background with yellow text, making it impossible to see.

In UWP however, it is just fine with a yellow background and black text.

How can I change the font color of the tracker to black?

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

Upvotes: 1

Views: 1250

Answers (1)

Anu Viswan
Anu Viswan

Reputation: 18153

You can change the default colors of Oxyplot Tracker by modifying the Control Template. For example,

 <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>

Of course, you can set the binding as well in the above, but for the sake of example, given the color directly in above example.

Upvotes: 2

Related Questions