Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manually created PlotView does not appear #1923

Closed
lukaszksoll opened this issue Aug 21, 2022 · 3 comments
Closed

Manually created PlotView does not appear #1923

lukaszksoll opened this issue Aug 21, 2022 · 3 comments

Comments

@lukaszksoll
Copy link

Hi! I have a problem after OxyPlot update from 2.0.0 to 2.1.0. Currently I cannot display a manually created (in code-behind) PlotView within the tooltip of the canvas. I tried to reproduce it on simpler example and it seems to behave the same.

In the following example tooltip is always empty. It contains proper size control, but there is no chart on the view. Within the comments you can find some code that works, but without tooltip.

When I'm trying to do this implementing PlotView in xaml code via VM - it works.

MainWindow.xaml.cs:

public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            var plotModel = new PlotModel
            {
                Title = "Long axis titles (clipped at 100%)",
                Series = { new FunctionSeries(Math.Cos, 0, 10, 400) },
            };
            var plotView = new PlotView
            {
                Model = plotModel,
                Width = 400,
                Height = 400,
            };

            var tooltip = new ToolTip { Content = plotView };

            // It works
            //var grid = new Grid()
            //{
            //    Children = { plotView }
            //};
            //Main.Content = grid;

            // It doesn't work
            var grid = new Grid
            {
                Width = 400,
                Height = 500,
                Background = Brushes.Red,
                ToolTip = tooltip,
            };

            grid.ToolTipOpening += (s, args) => plotView.InvalidatePlot();
            Main.Content = grid;


            plotView.InvalidatePlot();
        }
    }

MainWindow.xaml:

<Window x:Class="WpfApp1.MainWindow"
       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
       xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
       xmlns:local="clr-namespace:WpfApp1"
       mc:Ignorable="d"
       Title="MainWindow" Height="450" Width="800" x:Name="Main">

</Window>

Platform:
.NET version: 4.8/6.0
Oxyplot version: 2.1.0

Thank you for your help!

@VisualMelon
Copy link
Contributor

Sounds like #1796

Are you able to test a pre-release version?

@lukaszksoll
Copy link
Author

Yes, you're right. That's the problem. Are there any plans to release a fix for that?

@VisualMelon
Copy link
Contributor

This should be fixed in the 2.1.2 release. Closing, but feel free to re-open if there is still a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants