Search code examples
wpfoxyplot

Change color of zoom rectangle


I'm using OxyPlot in my application. I want to change the color of the rectangle when marking an area for zooming.

I just used Controller to bind the left mouse button to zoom:

ChartController = new PlotController(); 
ChartController.BindMouseDown(OxyMouseButton.Left,PlotCommands.ZoomRectangle);

Solution

  • To Color the Zoom Rectangle in Oxyplot, you can customize the ZoomRectangleTemplate.

    For Example,

    <oxy:PlotView Model="{Binding MyModel}" Controller="{Binding ChartController,UpdateSourceTrigger=PropertyChanged}">
            <oxy:PlotView.ZoomRectangleTemplate>
                <ControlTemplate>
                    <Border BorderBrush="Black" BorderThickness="1">
                        <Rectangle Fill="Orange" />
                    </Border>
                </ControlTemplate>
            </oxy:PlotView.ZoomRectangleTemplate>
    </oxy:PlotView>
    

    This would provide you the desired output

    enter image description here