how to use canvas.SetLeft on DateTime in wpfWhat is the correct way to create a single-instance WPF application?How do I use WPF bindings with RelativeSource?In WPF, what are the differences between the x:Name and Name attributes?WPF - ScreenSaver graphics performance improvementsHow do I exit a WPF application programmatically?Drawing lines and ellipses using ObservableCollection and ItemsControlWhy does a databinding for a Path's fill work but any binding for any of its child elements don't?How to draw simple shapes onto a WPF xaml-defined canvas programaticallyNew row in Binded DataGrid shows DatePicker as 01/01/0001How to WPF draw rectangle on top of image view dragged onto canvas

Why not use SQL instead of GraphQL?

How do I create uniquely male characters?

Problem of parity - Can we draw a closed path made up of 20 line segments...

How to find program name(s) of an installed package?

To string or not to string

Is it unprofessional to ask if a job posting on GlassDoor is real?

How to write a macro that is braces sensitive?

Smoothness of finite-dimensional functional calculus

Why Is Death Allowed In the Matrix?

Is it possible to do 50 km distance without any previous training?

Why do falling prices hurt debtors?

Can an x86 CPU running in real mode be considered to be basically an 8086 CPU?

What typically incentivizes a professor to change jobs to a lower ranking university?

What would happen to a modern skyscraper if it rains micro blackholes?

What defenses are there against being summoned by the Gate spell?

How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?

How can I make my BBEG immortal short of making them a Lich or Vampire?

"to be prejudice towards/against someone" vs "to be prejudiced against/towards someone"

Risk of getting Chronic Wasting Disease (CWD) in the United States?

Theorem, big Paralist and Amsart

Is it tax fraud for an individual to declare non-taxable revenue as taxable income? (US tax laws)

How to format long polynomial?

How is it possible to have an ability score that is less than 3?

Today is the Center



how to use canvas.SetLeft on DateTime in wpf


What is the correct way to create a single-instance WPF application?How do I use WPF bindings with RelativeSource?In WPF, what are the differences between the x:Name and Name attributes?WPF - ScreenSaver graphics performance improvementsHow do I exit a WPF application programmatically?Drawing lines and ellipses using ObservableCollection and ItemsControlWhy does a databinding for a Path's fill work but any binding for any of its child elements don't?How to draw simple shapes onto a WPF xaml-defined canvas programaticallyNew row in Binded DataGrid shows DatePicker as 01/01/0001How to WPF draw rectangle on top of image view dragged onto canvas






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















Sesaonallist is an ObservableCollection of type DataPoint.



I am trying to write each datapoint within the observable collection as an ellipse and draw it to a canvas. The problem is that X axis is of DateTime and I get the error




cannot convert DateTime to double




when I use Canvas.SetLeft(ellipse, Seasonallist[i].X);.



I don't want to use any third party libraries to do this, should i look into Converters?



Seasonallist = new ObservableCollection<DataPoint>();

if (Seasonallist != null)

for (int i = 0; i <= Seasonallist.Count - 1; i++)

Ellipse ellipse = new Ellipse();
ellipse.Width = 5;
ellipse.Height = 5;
ellipse.Fill = Brushes.Blue;
Canvas.SetLeft(ellipse, Seasonallist[i].X); <--error here
Canvas.SetTop(ellipse, Seasonallist.Y);
textCanvas.Children.Add(ellipse);



public class DataPoint

public DateTime X get; set;
public double Y get; set;










share|improve this question






























    0















    Sesaonallist is an ObservableCollection of type DataPoint.



    I am trying to write each datapoint within the observable collection as an ellipse and draw it to a canvas. The problem is that X axis is of DateTime and I get the error




    cannot convert DateTime to double




    when I use Canvas.SetLeft(ellipse, Seasonallist[i].X);.



    I don't want to use any third party libraries to do this, should i look into Converters?



    Seasonallist = new ObservableCollection<DataPoint>();

    if (Seasonallist != null)

    for (int i = 0; i <= Seasonallist.Count - 1; i++)

    Ellipse ellipse = new Ellipse();
    ellipse.Width = 5;
    ellipse.Height = 5;
    ellipse.Fill = Brushes.Blue;
    Canvas.SetLeft(ellipse, Seasonallist[i].X); <--error here
    Canvas.SetTop(ellipse, Seasonallist.Y);
    textCanvas.Children.Add(ellipse);



    public class DataPoint

    public DateTime X get; set;
    public double Y get; set;










    share|improve this question


























      0












      0








      0








      Sesaonallist is an ObservableCollection of type DataPoint.



      I am trying to write each datapoint within the observable collection as an ellipse and draw it to a canvas. The problem is that X axis is of DateTime and I get the error




      cannot convert DateTime to double




      when I use Canvas.SetLeft(ellipse, Seasonallist[i].X);.



      I don't want to use any third party libraries to do this, should i look into Converters?



      Seasonallist = new ObservableCollection<DataPoint>();

      if (Seasonallist != null)

      for (int i = 0; i <= Seasonallist.Count - 1; i++)

      Ellipse ellipse = new Ellipse();
      ellipse.Width = 5;
      ellipse.Height = 5;
      ellipse.Fill = Brushes.Blue;
      Canvas.SetLeft(ellipse, Seasonallist[i].X); <--error here
      Canvas.SetTop(ellipse, Seasonallist.Y);
      textCanvas.Children.Add(ellipse);



      public class DataPoint

      public DateTime X get; set;
      public double Y get; set;










      share|improve this question
















      Sesaonallist is an ObservableCollection of type DataPoint.



      I am trying to write each datapoint within the observable collection as an ellipse and draw it to a canvas. The problem is that X axis is of DateTime and I get the error




      cannot convert DateTime to double




      when I use Canvas.SetLeft(ellipse, Seasonallist[i].X);.



      I don't want to use any third party libraries to do this, should i look into Converters?



      Seasonallist = new ObservableCollection<DataPoint>();

      if (Seasonallist != null)

      for (int i = 0; i <= Seasonallist.Count - 1; i++)

      Ellipse ellipse = new Ellipse();
      ellipse.Width = 5;
      ellipse.Height = 5;
      ellipse.Fill = Brushes.Blue;
      Canvas.SetLeft(ellipse, Seasonallist[i].X); <--error here
      Canvas.SetTop(ellipse, Seasonallist.Y);
      textCanvas.Children.Add(ellipse);



      public class DataPoint

      public DateTime X get; set;
      public double Y get; set;







      wpf






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 8 at 6:31









      RN92

      1,024725




      1,024725










      asked Mar 8 at 4:34









      masterinexmasterinex

      1672411




      1672411






















          2 Answers
          2






          active

          oldest

          votes


















          0














          you can try the Ticks Property of the DataTime.



          Canvas.SetLeft(ellipse, Convert.ToDouble(Seasonallist[i].X.Ticks));


          you have to find a good way to convert this big number into X Canvas coordination.






          share|improve this answer























          • okay, i have used the Ticks property, but it is giving a really huge number like Seasonallist[i].X.Ticks = 635241312000000000, can i just arbitrary divide that large number by some other number to reduce it to a smaller number ?

            – masterinex
            Mar 8 at 10:14


















          0














          Yes, you will need to use a converter but first you must determine the width of a time interval. This is best done using the ticks values so:



          TicksPerPixel is Display duration / Display Width



          You can then store this value and use formula DateTime.Ticks / TicksPerPixel to calculate the left property needed to draw it in the correct location.






          share|improve this answer

























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55056776%2fhow-to-use-canvas-setleft-on-datetime-in-wpf%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            you can try the Ticks Property of the DataTime.



            Canvas.SetLeft(ellipse, Convert.ToDouble(Seasonallist[i].X.Ticks));


            you have to find a good way to convert this big number into X Canvas coordination.






            share|improve this answer























            • okay, i have used the Ticks property, but it is giving a really huge number like Seasonallist[i].X.Ticks = 635241312000000000, can i just arbitrary divide that large number by some other number to reduce it to a smaller number ?

              – masterinex
              Mar 8 at 10:14















            0














            you can try the Ticks Property of the DataTime.



            Canvas.SetLeft(ellipse, Convert.ToDouble(Seasonallist[i].X.Ticks));


            you have to find a good way to convert this big number into X Canvas coordination.






            share|improve this answer























            • okay, i have used the Ticks property, but it is giving a really huge number like Seasonallist[i].X.Ticks = 635241312000000000, can i just arbitrary divide that large number by some other number to reduce it to a smaller number ?

              – masterinex
              Mar 8 at 10:14













            0












            0








            0







            you can try the Ticks Property of the DataTime.



            Canvas.SetLeft(ellipse, Convert.ToDouble(Seasonallist[i].X.Ticks));


            you have to find a good way to convert this big number into X Canvas coordination.






            share|improve this answer













            you can try the Ticks Property of the DataTime.



            Canvas.SetLeft(ellipse, Convert.ToDouble(Seasonallist[i].X.Ticks));


            you have to find a good way to convert this big number into X Canvas coordination.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 8 at 6:35









            Hakam FostokHakam Fostok

            5,74284470




            5,74284470












            • okay, i have used the Ticks property, but it is giving a really huge number like Seasonallist[i].X.Ticks = 635241312000000000, can i just arbitrary divide that large number by some other number to reduce it to a smaller number ?

              – masterinex
              Mar 8 at 10:14

















            • okay, i have used the Ticks property, but it is giving a really huge number like Seasonallist[i].X.Ticks = 635241312000000000, can i just arbitrary divide that large number by some other number to reduce it to a smaller number ?

              – masterinex
              Mar 8 at 10:14
















            okay, i have used the Ticks property, but it is giving a really huge number like Seasonallist[i].X.Ticks = 635241312000000000, can i just arbitrary divide that large number by some other number to reduce it to a smaller number ?

            – masterinex
            Mar 8 at 10:14





            okay, i have used the Ticks property, but it is giving a really huge number like Seasonallist[i].X.Ticks = 635241312000000000, can i just arbitrary divide that large number by some other number to reduce it to a smaller number ?

            – masterinex
            Mar 8 at 10:14













            0














            Yes, you will need to use a converter but first you must determine the width of a time interval. This is best done using the ticks values so:



            TicksPerPixel is Display duration / Display Width



            You can then store this value and use formula DateTime.Ticks / TicksPerPixel to calculate the left property needed to draw it in the correct location.






            share|improve this answer





























              0














              Yes, you will need to use a converter but first you must determine the width of a time interval. This is best done using the ticks values so:



              TicksPerPixel is Display duration / Display Width



              You can then store this value and use formula DateTime.Ticks / TicksPerPixel to calculate the left property needed to draw it in the correct location.






              share|improve this answer



























                0












                0








                0







                Yes, you will need to use a converter but first you must determine the width of a time interval. This is best done using the ticks values so:



                TicksPerPixel is Display duration / Display Width



                You can then store this value and use formula DateTime.Ticks / TicksPerPixel to calculate the left property needed to draw it in the correct location.






                share|improve this answer















                Yes, you will need to use a converter but first you must determine the width of a time interval. This is best done using the ticks values so:



                TicksPerPixel is Display duration / Display Width



                You can then store this value and use formula DateTime.Ticks / TicksPerPixel to calculate the left property needed to draw it in the correct location.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 8 at 10:24

























                answered Mar 8 at 10:18









                Matt NorrieMatt Norrie

                43111




                43111



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55056776%2fhow-to-use-canvas-setleft-on-datetime-in-wpf%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

                    Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

                    Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved