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

How do I find all files that end with a dot

Is it improper etiquette to ask your opponent what his/her rating is before the game?

How can Trident be so inexpensive? Will it orbit Triton or just do a (slow) flyby?

What is Cash Advance APR?

Closed-form expression for certain product

Why electric field inside a cavity of a non-conducting sphere not zero?

Is the U.S. Code copyrighted by the Government?

How to implement a feedback to keep the DC gain at zero for this conceptual passive filter?

Which one is correct as adjective “protruding” or “protruded”?

Not using 's' for he/she/it

Why should universal income be universal?

Can I sign legal documents with a smiley face?

What does chmod -u do?

Is it safe to use olive oil to clean the ear wax?

Why is it that I can sometimes guess the next note?

Is there a working SACD iso player for Ubuntu?

Why is so much work done on numerical verification of the Riemann Hypothesis?

If a character has darkvision, can they see through an area of nonmagical darkness filled with lightly obscuring gas?

If infinitesimal transformations commute why dont the generators of the Lorentz group commute?

Are the IPv6 address space and IPv4 address space completely disjoint?

Melting point of aspirin, contradicting sources

Create all possible words using a set or letters

Is there a name for this algorithm to calculate the concentration of a mixture of two solutions containing the same solute?

What was the exact wording from Ivanhoe of this advice on how to free yourself from slavery?



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













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

      926724




      926724










      asked Mar 8 at 4:34









      masterinexmasterinex

      1622311




      1622311






















          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,61284469




            5,61284469












            • 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

                39610




                39610



























                    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

                    Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

                    Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

                    How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page