Search code examples
c#wpfxamloxyplot

Oxyplot - Hiding Tick Mark Labels


I am trying to hide the first and last tick mark label on the x-axis. I've done it once via a style and style triggers, but that code has gone....somewhere. Here's what I'm working with.

<UserControl
    x:Class="PentagearRT.Controls.Graph"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:oxy="http://oxyplot.org/wpf"
    xmlns:local="clr-namespace:PentagearRT.Controls"
    mc:Ignorable="d"
    d:DesignHeight="500"
    d:DesignWidth="800">

    <Grid>
        <oxy:Plot>
            <oxy:Plot.Resources>
            </oxy:Plot.Resources>
            <oxy:Plot.Axes>
                <oxy:LinearAxis Position="Left" Minimum="-5" Maximum="5" MajorStep="1"
                                MajorGridlineColor="AliceBlue" MajorGridlineThickness=".07" MajorGridlineStyle="Dot"/>
                <oxy:LinearAxis Position="Bottom" Minimum="0" Maximum="360" MajorStep="45" StringFormat="0&#176;"
                                MajorGridlineColor="AliceBlue" MajorGridlineThickness=".07" MajorGridlineStyle="Dot"/>
            </oxy:Plot.Axes>
            <oxy:LineSeries Background="Black"/>

        </oxy:Plot>
    </Grid>

</UserControl>

Edit: What I'm trying to hide are the two values circled in red.

enter image description here


Solution

  • <oxy:Plot.Resources>
        <Style TargetType="TextBlock">
            <Style.Triggers>
                <Trigger Property="Text" Value="360°">
                    <Setter Property="Visibility" Value="Collapsed"/>
                </Trigger>
                <Trigger Property="Text" Value="0°">
                    <Setter Property="Visibility" Value="Collapsed"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </oxy:Plot.Resources>