How to find chart control under my toolbox?

Shay Wilner 1,746 Reputation points
2020-03-15T14:55:32.48+00:00

Hi
I 'm working with visual studio 2019 and try to add char control for uwp
Via the nuget package manager i installed winrtxamltoolkit.controls.datavisualization.uwp
4471-chart.png

But i don't know how to add the controls or where the dll are located ?

Thanks

Developer technologies Universal Windows Platform (UWP)
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. Peter Fleischer (former MVP) 19,341 Reputation points
    2020-03-15T18:21:03.337+00:00

    Hi,
    try this demo:

    <Page
        x:Class="UWP10App1VB.Page16"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:UWP10App1VB"
    
        xmlns:dvc="using:WinRTXamlToolkit.Controls.DataVisualization.Charting"
    
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
      <Page.DataContext>
        <local:Page16VM/>
      </Page.DataContext>
      <Grid>
        <dvc:Chart x:Name="LineChart">
          <dvc:LineSeries Title="Line 1" 
                          ItemsSource="{Binding Line1}"
                          IndependentValuePath="Col" 
                          DependentValuePath="Value" 
                          IsSelectionEnabled="False"/>
        </dvc:Chart>
      </Grid>
    </Page>
    

  2. dfergenson 1 Reputation point
    2021-03-08T20:56:01.23+00:00

    @Shay Wilner : For what it's worth, I think that I just went through what you are going through and I did figure out the answer. My problem wasn't identical but the solution very well might be very similar. I'll describe my issue below and you can respond with more precise advice if it helps point you in the right direction. And hopefully, someone in need of a chart control in a Windows Forms App will find their way here and this will solve their problem, too.

    The simple workaround is that, if you are creating an application to run on MS Windows and you need to use a Chart control in Visual Studio 2019, then you need to make sure that you INITIALLY create the application as a Windows Forms App (.NET Framework) and not as a Windows Forms App even though the names and their descriptions are nearly identical. There doesn't appear to be any way to switch between the two after the fact.

    75538-screen-shot-2021-03-08-at-115728-am.png

    This issue seemed to be the result of a confounding series of what I would describe as bugs but which I am open to being corrected about. Here's what I found when looking into this for myself:

    The chart control is not supported in the .NET 5 framework. It is NOT forward compatible from earlier frameworks. It simply doesn’t exist in .NET 5 in any way shape or form. This is annoying but far from terminal; one could simply use an earlier version of .NET. Except that that option is not available if one has created "A Windows Forms App: A project template for creating a .NET Windows Forms (WinForms) App." If one has done this, then there are three .NET targets that one can select, .NET 3.1, .NET 3.5 and .NET 5. But that’s okay because there’s an option below the selector to add more .NET targets except that... Doing so takes you to a website, where you can download an installer, install the frameworks and they still won’t be there.

    So, what one needs to do is, instead, create "A Windows Forms App (.NET Framework): A project for creating an application with a Windows Forms (WinForms) user interface." I'm sure that, to a trained eye, these two templates are totally different but frankly, as a person who develops technology myself, I can't imagine what whoever named and described these was thinking. If they're critically different, then they should be very differently named. And if they're not critically different, then they should be combined.

    If one has created an application from the correct template (which is down below the wrong one and out of sight by default), then one can select earlier versions of the .NET framework including .NET 4.8, the latest to support the chart control. Then the chart control should already be in the toolbox and, if not, it can be added the regular way (right click on the toolbox and select "Choose items...").

    My questions are these:
    Why aren't charts supported in .NET 5?
    Why can't to select an earlier version of the .NET framework other than 3.1 or 3.5 when developing a Windows Forms App?
    Why can't one to add earlier .NET versions successfully to a Windows Forms App? And, if this is impossible, then why give the illusion that it's possible and that it has, in fact, been accomplished only to make it remain out of reach?
    Why can’t one toggle between a Windows Forms App: A project template for creating a .NET Windows Forms (WinForms) App and a Windows Forms App (.NET Framework): A project for creating an application with a windows Forms (WinForms) user interface once the app has been created? This alone would have saved me from a lot of rework.
    Why are the two types of application templates named so similarly? The people who developed both frameworks control the technology AND the terminology. They could easily have distinguished between the two if there were a concrete difference. And if there isn’t a really good reason to have two of them then they should be combined.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.